Added project version / excludedpackages validation
authorAlexander Ebert <ebert@woltlab.com>
Thu, 13 Jul 2017 12:57:16 +0000 (14:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 13 Jul 2017 12:57:16 +0000 (14:57 +0200)
See #2331

wcfsetup/install/files/acp/templates/devtoolsProjectSync.tpl
wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e7750fe0efbbcfe827bdec1f81bd1390144f8793..dd49fb2dc695161989683dd8aecbe82dc82c1217 100644 (file)
                }
        </style>
 {else}
-       <p class="error">{$object->validate()}</p>
+       <p class="error">{@$object->validate()}</p>
 {/if}
 
 {include file='footer'}
index 6d036c39babb05bf2d700e81bfb0203f64365be4..f075b54fd6743a73e9c813f36aee50b95054c1f3 100644 (file)
@@ -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 '';
        }
        
index 83a16c381818a17ebf8d6975533cce863cc61a72..abbc07f3ef19db7d516fd98ce5d2cde47d2bbf18 100644 (file)
                <item name="wcf.acp.devtools.project.list"><![CDATA[Projekte]]></item>
                <item name="wcf.acp.devtools.project.name"><![CDATA[Name]]></item>
                <item name="wcf.acp.devtools.project.path"><![CDATA[Pfad]]></item>
+               <item name="wcf.acp.devtools.project.path.error.excludedVersion"><![CDATA[Die aktuelle Core-Version wird in der <kbd>package.xml</kbd> explizit ausgeschlossen.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[In der <kbd>package.xml</kbd> fehlt die <kbd>&gt;excludedpackage&lt;</kbd>-Anweisung für <kbd>com.woltlab.wcf</kbd>.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.notInstalled"><![CDATA[Das Paket muss bereits installiert sein.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.versionMismatch"><![CDATA[Die Version in der <kbd>package.xml</kbd> passt nicht zur installierten Version, möglicherweise wurde eine falsches Verzeichnis ausgewählt.]]></item>
                <item name="wcf.acp.devtools.project.sync"><![CDATA[Daten-Abgleich]]></item>
                <item name="wcf.acp.devtools.pip.defaultFilename"><![CDATA[Suchmuster]]></item>
                <item name="wcf.acp.devtools.pip.error.notIdempotent"><![CDATA[Das PIP unterstützt keinen wiederholten Import und kann nur bei einem Update verarbeitet werden.]]></item>
index 28a683b34a2fe9f3e901402dd099b4bcbbcb2140..bd2d8822549c6dd008a59fd7d1b97c1e693df2dc 100644 (file)
                <item name="wcf.acp.devtools.project.list"><![CDATA[Projects]]></item>
                <item name="wcf.acp.devtools.project.name"><![CDATA[Name]]></item>
                <item name="wcf.acp.devtools.project.path"><![CDATA[Path]]></item>
+               <item name="wcf.acp.devtools.project.path.error.excludedVersion"><![CDATA[The current Core-version is explicitly listed as excluded in the <kbd>package.xml</kbd>.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[The <kbd>package.xml</kbd> is missing the <kbd>&gt;excludedpackage&lt;</kbd>-instruction for <kbd>com.woltlab.wcf</kbd>.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.notInstalled"><![CDATA[The package must be installed already.]]></item>
+               <item name="wcf.acp.devtools.project.path.error.versionMismatch"><![CDATA[The version shown in the <kbd>package.xml</kbd> does not match the installed version, you may have selected the wrong path.]]></item>
                <item name="wcf.acp.devtools.project.sync"><![CDATA[Sync Data]]></item>
                <item name="wcf.acp.devtools.pip.defaultFilename"><![CDATA[Searchpattern]]></item>
                <item name="wcf.acp.devtools.pip.error.notIdempotent"><![CDATA[This PIP does not support repeated imports and can only be processed in regular updates.]]></item>