From 67958915da26eade597b1fcb3764f5c793fa27e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 9 Nov 2023 15:57:22 +0100 Subject: [PATCH] =?UTF-8?q?fix(events):=20Make=20sure=20all=20`\OCP\Files:?= =?UTF-8?q?:=E2=80=A6`=20events=20are=20emitted=20with=20the=20same=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Joas Schilling --- lib/private/Files/Node/Node.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 1fdedd844aef4..acd91c56d3f68 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -132,7 +132,14 @@ protected function sendHooks($hooks, array $args = null) { if (method_exists($this->root, 'emit')) { $this->root->emit('\OC\Files', $hook, $args); } - $dispatcher->dispatch('\OCP\Files::' . $hook, new GenericEvent($args)); + + if (in_array($hook, ['preWrite', 'postWrite', 'preCreate', 'postCreate', 'preTouch', 'postTouch', 'preDelete', 'postDelete'], true)) { + $event = new GenericEvent($args[0]); + } else { + $event = new GenericEvent($args); + } + + $dispatcher->dispatch('\OCP\Files::' . $hook, $event); } }