From 31cbb98f46b935ab05cf062267aeadcb6a0810ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 16 Nov 2022 12:12:39 +0100 Subject: [PATCH] Add PackageArchive::getUpdateInstructionsFor() --- .../lib/system/package/PackageArchive.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 84297fb0b9..4f7847cfd1 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -630,6 +630,23 @@ class PackageArchive return $this->instructions['update']; } + /** + * Returns the appropriate update instructions to update the given package, + * `null` if no appropriate instruction could be found. + * + * @since 6.0 + */ + public function getUpdateInstructionsFor(Package $package): ?array + { + foreach ($this->instructions['update'] as $fromVersion => $instructions) { + if (Package::checkFromversion($package->packageVersion, $fromVersion)) { + return $instructions; + } + } + + return null; + } + /** * Checks which package requirements do already exist in database. * Returns a list with the existing requirements. -- 2.20.1