Lazily filter update instructions in PackageArchive
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 18 Nov 2022 09:27:42 +0000 (10:27 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 18 Nov 2022 10:00:50 +0000 (11:00 +0100)
As `$this->package` is effectively readonly, this is safe and will not change
the behavior.

wcfsetup/install/files/lib/system/package/PackageArchive.class.php

index 422ee208e2d10cb98b64aa2166f95976023bd996..41f3c1f6ded6a35ee82e322944763be226b157c0 100644 (file)
@@ -420,13 +420,6 @@ class PackageArchive
             }
         }
 
-        // during installations, `Package::$packageVersion` can be `null` which causes issues
-        // in `PackageArchive::filterUpdateInstructions()`; as update instructions are not needed
-        // for installations, not filtering update instructions is okay
-        if ($this->package !== null && $this->package->packageVersion !== null) {
-            $this->filterUpdateInstructions();
-        }
-
         // set default values
         if (!isset($this->packageInfo['isApplication'])) {
             $this->packageInfo['isApplication'] = 0;
@@ -595,6 +588,10 @@ class PackageArchive
      */
     public function getUpdateInstructions()
     {
+        if ($this->package !== null && $this->package->packageVersion !== null) {
+            $this->filterUpdateInstructions();
+        }
+
         return $this->instructions['update'];
     }