Skip to content

Commit efdbd45

Browse files
Messj1miaulalala
authored andcommitted
fix access array offset which doesn't exist
Successor hook fileMovePost is only processed if no error occured in fileMove hook Signed-off-by: Jan Messer <[email protected]>
1 parent bdffd79 commit efdbd45

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/FilesHooks.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ public function fileMove($oldPath, $newPath) {
242242
return;
243243
}
244244

245+
// cache moveCase result until attributes are calculated for next stage (fileMovePost)
246+
// moveCase has to be set as last part before return
247+
$moveCase = $this->moveCase;
245248
if (strpos($oldDir, $newDir) === 0) {
246249
/**
247250
* a/b/c moved to a/c
@@ -251,7 +254,7 @@ public function fileMove($oldPath, $newPath) {
251254
* - a/b/ shared: delete
252255
* - a/ shared: move/rename
253256
*/
254-
$this->moveCase = 'moveUp';
257+
$moveCase = 'moveUp';
255258
} elseif (strpos($newDir, $oldDir) === 0) {
256259
/**
257260
* a/b moved to a/c/b
@@ -261,7 +264,7 @@ public function fileMove($oldPath, $newPath) {
261264
* - a/c/ shared: add
262265
* - a/ shared: move/rename
263266
*/
264-
$this->moveCase = 'moveDown';
267+
$moveCase = 'moveDown';
265268
} else {
266269
/**
267270
* a/b/c moved to a/d/c
@@ -272,7 +275,7 @@ public function fileMove($oldPath, $newPath) {
272275
* - a/d/ shared: add
273276
* - a/ shared: move/rename
274277
*/
275-
$this->moveCase = 'moveCross';
278+
$moveCase = 'moveCross';
276279
}
277280

278281
[$this->oldParentPath, $this->oldParentOwner, $this->oldParentId] = $this->getSourcePathAndOwner($oldDir);
@@ -291,6 +294,9 @@ public function fileMove($oldPath, $newPath) {
291294
}
292295

293296
$this->oldAccessList = $oldAccessList;
297+
298+
// now its save to set moveCase
299+
$this->moveCase = $moveCase;
294300
}
295301

296302

0 commit comments

Comments
 (0)