]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: don't emit Hooks when hookpaths are empty 39481/head
authorAnna Larch <anna@nextcloud.com>
Wed, 19 Jul 2023 14:39:04 +0000 (16:39 +0200)
committerAnna Larch <anna@nextcloud.com>
Thu, 17 Aug 2023 07:32:14 +0000 (09:32 +0200)
Signed-off-by: Anna Larch <anna@nextcloud.com>
lib/private/Files/View.php

index d256003537d4815317630c86e37a56965c7e6e1f..718159393100953dc862834128947fd2ac5df136 100644 (file)
@@ -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,
+                                                                       ]
+                                                               );
+                                                       }
                                                }
                                        }
                                }