Skip to content

Commit 151c6bd

Browse files
committed
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 fa1aedd commit 151c6bd

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
@@ -234,6 +234,9 @@ public function fileMove($oldPath, $newPath) {
234234
return;
235235
}
236236

237+
// cache moveCase result until attributes are calculated for next stage (fileMovePost)
238+
// moveCase has to be set as last part before return
239+
$moveCase = $this->moveCase;
237240
if (strpos($oldDir, $newDir) === 0) {
238241
/**
239242
* a/b/c moved to a/c
@@ -243,7 +246,7 @@ public function fileMove($oldPath, $newPath) {
243246
* - a/b/ shared: delete
244247
* - a/ shared: move/rename
245248
*/
246-
$this->moveCase = 'moveUp';
249+
$moveCase = 'moveUp';
247250
} elseif (strpos($newDir, $oldDir) === 0) {
248251
/**
249252
* a/b moved to a/c/b
@@ -253,7 +256,7 @@ public function fileMove($oldPath, $newPath) {
253256
* - a/c/ shared: add
254257
* - a/ shared: move/rename
255258
*/
256-
$this->moveCase = 'moveDown';
259+
$moveCase = 'moveDown';
257260
} else {
258261
/**
259262
* a/b/c moved to a/d/c
@@ -264,7 +267,7 @@ public function fileMove($oldPath, $newPath) {
264267
* - a/d/ shared: add
265268
* - a/ shared: move/rename
266269
*/
267-
$this->moveCase = 'moveCross';
270+
$moveCase = 'moveCross';
268271
}
269272

270273
[$this->oldParentPath, $this->oldParentOwner, $this->oldParentId] = $this->getSourcePathAndOwner($oldDir);
@@ -283,6 +286,9 @@ public function fileMove($oldPath, $newPath) {
283286
}
284287

285288
$this->oldAccessList = $oldAccessList;
289+
290+
// now its save to set moveCase
291+
$this->moveCase = $moveCase;
286292
}
287293

288294

0 commit comments

Comments
 (0)