From: Matthias Schmidt Date: Tue, 13 Apr 2021 15:06:56 +0000 (+0200) Subject: Only create one `DevtoolsPackageArchive` object in `DevtoolsProject` X-Git-Tag: 5.4.0_Alpha_1~95^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bfb9ac09aa7ddb37389fb9efd9156be3ae106c91;p=GitHub%2FWoltLab%2FWCF.git Only create one `DevtoolsPackageArchive` object in `DevtoolsProject` --- 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 f6164a63d9..3c4f41c472 100644 --- a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php +++ b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php @@ -50,6 +50,12 @@ class DevtoolsProject extends DatabaseObject */ protected $packageArchive; + /** + * @var PackageValidationException + * @since 5.4 + */ + protected $packageValidationException; + /** * Returns a list of decorated PIPs. * @@ -123,12 +129,11 @@ class DevtoolsProject extends DatabaseObject */ public function validatePackageXml() { - $packageXml = $this->getPackageXmlPath(); - $this->packageArchive = new DevtoolsPackageArchive($packageXml); - try { - $this->packageArchive->openArchive(); - } catch (PackageValidationException $e) { - return $e->getErrorMessage(); + // Make sure that the package archive is read and any validation exception while opening the + // archive is caught. + $this->getPackageArchive(); + if ($this->packageValidationException) { + return $this->packageValidationException->getErrorMessage(); } if ($this->getPackage() === null) { @@ -180,13 +185,12 @@ class DevtoolsProject extends DatabaseObject public function getPackageArchive() { if ($this->packageArchive === null) { - $this->packageArchive = new DevtoolsPackageArchive($this->path . ($this->isCore() ? 'com.woltlab.wcf/' : '') . 'package.xml'); + $this->packageArchive = new DevtoolsPackageArchive($this->getPackageXmlPath()); try { $this->packageArchive->openArchive(); } catch (PackageValidationException $e) { - // we do not care for errors here, `validatePackageXml()` - // takes care of that + $this->packageValidationException = $e; } }