diff options
author | Anna <anna@nextcloud.com> | 2023-08-21 09:06:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-21 09:06:18 +0200 |
commit | fcaa6760afbc67d1db7104acab00f61fc4592068 (patch) | |
tree | 4376a1e4d8f4e76af9000b971418a4897bd7c2c9 /lib | |
parent | 61ee7be033c2ce1be548ced4bec5838b5729dde2 (diff) | |
parent | fe26271c78da9d420dce8b2d74165e71c1db199d (diff) | |
download | nextcloud-server-fcaa6760afbc67d1db7104acab00f61fc4592068.tar.gz nextcloud-server-fcaa6760afbc67d1db7104acab00f61fc4592068.zip |
Merge pull request #39935 from nextcloud/fix/stable26/transfer-ownership
[stable26] fix: don't emit Hooks when hookpaths are empty
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/View.php | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 1bd131303e3..95ad46ec554 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -781,14 +781,18 @@ class View { // if it was a rename from a part file to a regular file it was a write and not a rename operation $this->emit_file_hooks_pre($exists, $target, $run); } elseif ($this->shouldEmitHooks($source)) { - \OC_Hook::emit( - Filesystem::CLASSNAME, Filesystem::signal_rename, - [ - Filesystem::signal_param_oldpath => $this->getHookPath($source), - Filesystem::signal_param_newpath => $this->getHookPath($target), - Filesystem::signal_param_run => &$run - ] - ); + $sourcePath = $this->getHookPath($source); + $targetPath = $this->getHookPath($target); + if ($sourcePath !== null && $targetPath !== null) { + \OC_Hook::emit( + Filesystem::CLASSNAME, Filesystem::signal_rename, + [ + Filesystem::signal_param_oldpath => $sourcePath, + Filesystem::signal_param_newpath => $targetPath, + Filesystem::signal_param_run => &$run + ] + ); + } } if ($run) { $this->verifyPath(dirname($target), basename($target)); @@ -853,15 +857,19 @@ class View { $this->emit_file_hooks_post($exists, $target); } } elseif ($result) { - if ($this->shouldEmitHooks($source) and $this->shouldEmitHooks($target)) { - \OC_Hook::emit( - Filesystem::CLASSNAME, - Filesystem::signal_post_rename, - [ - Filesystem::signal_param_oldpath => $this->getHookPath($source), - Filesystem::signal_param_newpath => $this->getHookPath($target) - ] - ); + if ($this->shouldEmitHooks($source) && $this->shouldEmitHooks($target)) { + $sourcePath = $this->getHookPath($source); + $targetPath = $this->getHookPath($target); + if ($sourcePath !== null && $targetPath !== null) { + \OC_Hook::emit( + Filesystem::CLASSNAME, + Filesystem::signal_post_rename, + [ + Filesystem::signal_param_oldpath => $sourcePath, + Filesystem::signal_param_newpath => $targetPath, + ] + ); + } } } } |