From 6f7fe63b2732e24f178bad4f97aa950a5d71cf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 13 Feb 2023 14:30:40 +0100 Subject: [PATCH] fix: Make sure that rollback hook is triggered on all version backends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_versions/lib/Storage.php | 6 ------ apps/files_versions/lib/Versions/VersionManager.php | 8 +++++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 2fd208cd3644e..cbd15f1cb3ed3 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -416,12 +416,6 @@ public static function rollback(string $file, int $revision, IUser $user) { $node = $userFolder->get($file); - // TODO: move away from those legacy hooks! - \OC_Hook::emit('\OCP\Versions', 'rollback', [ - 'path' => $filename, - 'revision' => $revision, - 'node' => $node, - ]); return true; } elseif ($versionCreated) { self::deleteVersion($users_view, $version); diff --git a/apps/files_versions/lib/Versions/VersionManager.php b/apps/files_versions/lib/Versions/VersionManager.php index bfae0937df81d..c11b429202bdf 100644 --- a/apps/files_versions/lib/Versions/VersionManager.php +++ b/apps/files_versions/lib/Versions/VersionManager.php @@ -94,7 +94,13 @@ public function createVersion(IUser $user, FileInfo $file) { public function rollback(IVersion $version) { $backend = $version->getBackend(); - return $backend->rollback($version); + $result = $backend->rollback($version); + \OC_Hook::emit('\OCP\Versions', 'rollback', [ + 'path' => \OC\Files\Filesystem::getView()->getRelativePath($version->getSourceFile()->getPath()), + 'revision' => $version->getRevisionId(), + 'node' => $version->getSourceFile(), + ]); + return $result; } public function read(IVersion $version) {