Skip to content

Commit b289d14

Browse files
committed
log warnings to give admins more infos about possibly miscalculated activities.
Signed-off-by: Jan Messer <jan@mtec-studios.ch>
1 parent f391183 commit b289d14

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/FilesHooks.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,16 @@ protected function fileMoving($oldPath, $newPath) {
396396
}
397397
$accessList = $this->getUserPathsFromPath($parentPath, $parentOwner);
398398
$affectedUsers = $accessList['users'];
399-
$oldUsers = $this->oldAccessList['users'] ?? [];
399+
$oldAccessList = $this->oldAccessList;
400+
if($oldAccessList === null) {
401+
$this->logger->warning("Something fishy happens: function fileMove was not finished: {oldPath} -> {path} : {uidOwner}",
402+
['oldPath'=>$oldPath, 'path'=> $parentPath, 'uidOwner'=>$parentOwner]);
403+
$oldAccessList = [
404+
'users' => [],
405+
'remotes' => [],
406+
];
407+
}
408+
$oldUsers = $oldAccessList['users'];
400409

401410
// file can be shared using GroupFolders, including ACL check
402411
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
@@ -416,7 +425,7 @@ protected function fileMoving($oldPath, $newPath) {
416425
$moveUsers = array_intersect($beforeUsers, $afterUsers);
417426
$this->generateMoveActivities($moveUsers, $oldUsers, $affectedUsers, $fileId, $oldFileName, $parentId, $fileName);
418427

419-
$beforeRemotes = $this->oldAccessList['remotes'] ?? [];
428+
$beforeRemotes = $oldAccessList['remotes'];
420429
$afterRemotes = $accessList['remotes'];
421430

422431
$addRemotes = $deleteRemotes = $moveRemotes = [];
@@ -570,13 +579,17 @@ protected function getUserPathsFromPath($path, $uidOwner) {
570579
try {
571580
$node = $this->rootFolder->getUserFolder($uidOwner)->get($path);
572581
} catch (NotFoundException $e) {
582+
$this->logger->warning('Something fishy happens: Path "{path}" with owner "{uidOwner}" was not found',
583+
['path'=> $path, 'uidOwner'=>$uidOwner]);
573584
return [
574585
'users' => [],
575586
'remotes' => [],
576587
];
577588
}
578589

579590
if (!$node instanceof Node) {
591+
$this->logger->warning('Something fishy happens: Path "{path}" of "{uidOwner}" is not a valid type.',
592+
['path'=> $path, 'uidOwner'=>$uidOwner]);
580593
return [
581594
'users' => [],
582595
'remotes' => [],

0 commit comments

Comments
 (0)