diff options
author | Anna Larch <anna@nextcloud.com> | 2023-07-19 16:39:04 +0200 |
---|---|---|
committer | Anna <anna@nextcloud.com> | 2023-08-21 09:58:21 +0200 |
commit | 818ddb02c5b99623b15c8de49ce60dda11095b88 (patch) | |
tree | e6f640060dccf296b6f87dede292d8bbcaaf2a0c /lib | |
parent | c735c6f67a9adfa66ad548d79f4288a7243d4266 (diff) | |
download | nextcloud-server-818ddb02c5b99623b15c8de49ce60dda11095b88.tar.gz nextcloud-server-818ddb02c5b99623b15c8de49ce60dda11095b88.zip |
fix: don't emit Hooks when hookpaths are empty
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/View.php | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index a73b60989fd..05b4b2e21b8 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -744,14 +744,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)); @@ -817,14 +821,18 @@ class View { } } elseif ($result) { if ($this->shouldEmitHooks($source) && $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) - ] - ); + $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, + ] + ); + } } } } |