From d2b357c6115c595ff277df6047e7e91fb7b7960d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 13 Jul 2017 14:57:16 +0200 Subject: [PATCH] Added project version / excludedpackages validation See #2331 --- .../acp/templates/devtoolsProjectSync.tpl | 2 +- .../project/DevtoolsProject.class.php | 33 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 4 +++ wcfsetup/install/lang/en.xml | 4 +++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/devtoolsProjectSync.tpl b/wcfsetup/install/files/acp/templates/devtoolsProjectSync.tpl index e7750fe0ef..dd49fb2dc6 100644 --- a/wcfsetup/install/files/acp/templates/devtoolsProjectSync.tpl +++ b/wcfsetup/install/files/acp/templates/devtoolsProjectSync.tpl @@ -111,7 +111,7 @@ } {else} -

{$object->validate()}

+

{@$object->validate()}

{/if} {include file='footer'} diff --git a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php index 6d036c39ba..f075b54fd6 100644 --- a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php +++ b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php @@ -106,6 +106,39 @@ class DevtoolsProject extends DatabaseObject { ]); } + $normalizeVersion = function($version) { + return preg_replace('~^(\d+)\.(\d+)\..*$~', '\\1.\\2', $version); + }; + + if ($normalizeVersion($this->packageArchive->getPackageInfo('version')) !== $normalizeVersion($this->package->packageVersion)) { + return WCF::getLanguage()->getDynamicVariable('wcf.acp.devtools.project.path.error.versionMismatch', [ + 'version' => $this->packageArchive->getPackageInfo('version'), + 'packageVersion' => $this->package->packageVersion + ]); + } + + if (!$this->isCore()) { + $hasValidExclude = false; + $foundCore = false; + foreach ($this->packageArchive->getExcludedPackages() as $excludedPackage) { + if ($excludedPackage['name'] !== 'com.woltlab.wcf') continue; + + $foundCore = true; + if (Package::compareVersion(WCF_VERSION, $excludedPackage['version'], '<')) { + $hasValidExclude = true; + break; + } + } + + if (!$hasValidExclude) { + if (!$foundCore) { + return WCF::getLanguage()->get('wcf.acp.devtools.project.path.error.missingExclude'); + } + + return WCF::getLanguage()->get('wcf.acp.devtools.project.path.error.excludedVersion'); + } + } + return ''; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 83a16c3818..abbc07f3ef 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -377,6 +377,10 @@ + package.xml explizit ausgeschlossen.]]> + package.xml fehlt die >excludedpackage<-Anweisung für com.woltlab.wcf.]]> + + package.xml passt nicht zur installierten Version, möglicherweise wurde eine falsches Verzeichnis ausgewählt.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 28a683b34a..bd2d882254 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -360,6 +360,10 @@ + package.xml.]]> + package.xml is missing the >excludedpackage<-instruction for com.woltlab.wcf.]]> + + package.xml does not match the installed version, you may have selected the wrong path.]]> -- 2.20.1