From 47584380bf69baf1c1fc48ccd913f3f73c820edc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 1 Jul 2020 14:30:10 +0200 Subject: [PATCH] Add instruction The instruction may only be used during updates and only when no other package installation plugin is used. It will result in a noop when running the upgrade, allowing an upgrade to adjust package metadata without actually changing anything. Example usage: Resolves #3411 --- .../system/package/PackageArchive.class.php | 24 +++++++++++++++++++ .../PackageInstallationDispatcher.class.php | 4 ++++ .../PackageValidationException.class.php | 12 ++++++++++ wcfsetup/install/lang/de.xml | 2 ++ wcfsetup/install/lang/en.xml | 2 ++ 5 files changed, 44 insertions(+) diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index e67a9b5c41..1e9d500883 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -88,6 +88,12 @@ class PackageArchive { */ const INFO_FILE = 'package.xml'; + /** + * marker for the void instruction + * @var string + */ + const VOID_MARKER = "===void==="; + /** * Creates a new PackageArchive object. * @@ -351,6 +357,24 @@ class PackageArchive { $fromVersion = $element->getAttribute('fromversion'); $type = $element->getAttribute('type'); + $void = $xpath->query('./ns:void', $element); + if ($void->length > 1) { + throw new PackageValidationException(PackageValidationException::VOID_NOT_ALONE); + } + else if ($void->length == 1) { + if (!empty($instructionData)) { + throw new PackageValidationException(PackageValidationException::VOID_NOT_ALONE); + } + if ($type == 'install') { + throw new PackageValidationException(PackageValidationException::VOID_ON_INSTALL); + } + + $instructionData[] = [ + 'pip' => self::VOID_MARKER, + 'value' => '', + ]; + } + if ($type == 'install') { $this->instructions['install'] = $instructionData; } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index ae1024bb90..e2621d57c0 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -703,6 +703,10 @@ class PackageInstallationDispatcher { protected function executePIP(array $nodeData) { $step = new PackageInstallationStep(); + if ($nodeData['pip'] == PackageArchive::VOID_MARKER) { + return $step; + } + // fetch all pips associated with current PACKAGE_ID and include pips // previously installed by current installation queue $sql = "SELECT pluginName, className diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php index 4f01326166..bf8971d688 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php @@ -114,6 +114,18 @@ class PackageValidationException extends SystemException { */ const MISSING_API_VERSION = 15; + /** + * the void is not the only instruction + * @var integer + */ + const VOID_NOT_ALONE = 16; + + /** + * the void is used during installation + * @var integer + */ + const VOID_ON_INSTALL = 17; + /** * Creates a new PackageArchiveValidationException. * diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 47205e2360..7e437bbe23 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1937,6 +1937,8 @@ Die Datenbestände werden sorgfältig gepflegt, aber es ist nicht ausgeschlossen + + {$packageName} ist abgelaufen. Bitte aktualisiere{if !LANGUAGE_USE_INFORMAL_VARIANT}n Sie{/if} auf die aktuellste Version um diese Software weiterhin legal betreiben zu können.{if $pluginStoreFileID || $isWoltLab}
{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die aktuelle Version sicher und bequem {if $pluginStoreFileID}im WoltLab Plugin-Store{else}auf WoltLab.com{/if} erwerben.{/if}]]>
{$evaluationEndDate|plainTime} ({@$evaluationEndDate|dateDiff:TIME_NOW:true}) ablaufen. Mit Ablauf der Frist deaktiviert sich die App automatisch, es ist dann notwendig diese auf die endgültige Version zu aktualisieren, um den legalen Betrieb fortzusetzen. diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 6e28519c94..0e3f655dac 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1921,6 +1921,8 @@ The database is carefully maintained, but there will be always be a margin of er + + {$packageName} has expired. For a legal use of this software, please update to the latest available version.{if $pluginStoreFileID || $isWoltLab}
The latest version can be purchased quickly and securely {if $pluginStoreFileID}in the WoltLab Plugin-Store{else}on WoltLab.com{/if}.{/if}]]>
{$evaluationEndDate|plainTime} ({@$evaluationEndDate|dateDiff:TIME_NOW:true}). The apps will automatically disable themselves after this date and become unusable, you'll need to install the latest versions of the apps to active them again. -- 2.20.1