Reset OPcache after writing an updated bootstrap loader
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 29 Sep 2023 09:18:10 +0000 (11:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 29 Sep 2023 09:18:10 +0000 (11:18 +0200)
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/package/command/RebuildBootstrapper.class.php

index 4b6ccd6bbbc8a8457c0fadb94f31f56297e912d3..d70dd3f422f992a34236c8563f64871368e25310 100644 (file)
@@ -177,6 +177,8 @@ class WCF
      */
     protected static $zendOpcacheEnabled;
 
+    public const BOOTSTRAP_LOADER = \WCF_DIR . '/lib/bootstrap.php';
+
     /**
      * Calls all init functions of the WCF class.
      */
@@ -207,14 +209,14 @@ class WCF
     final protected function runBootstrappers(): void
     {
         try {
-            $bootstrappers = require(\WCF_DIR . 'lib/bootstrap.php');
+            $bootstrappers = require(self::BOOTSTRAP_LOADER);
         } catch (\Exception $e) {
             \wcf\functions\exception\logThrowable($e);
 
             $command = new RebuildBootstrapper();
             $command();
 
-            $bootstrappers = require(\WCF_DIR . 'lib/bootstrap.php');
+            $bootstrappers = require(self::BOOTSTRAP_LOADER);
         }
 
         foreach ($bootstrappers as $bootstrapper) {
index 72a70456bc38001d562f7249aab75fd306c3149c..4644ef31181d7bd3ed49c7f18abb395b1d119cb8 100644 (file)
@@ -5,6 +5,7 @@ namespace wcf\system\package\command;
 use wcf\data\package\Package;
 use wcf\data\package\PackageList;
 use wcf\system\io\AtomicWriter;
+use wcf\system\WCF;
 
 /**
  * Rebuilds the bootstrapping script.
@@ -67,9 +68,11 @@ final class RebuildBootstrapper
             EOT;
         $result .= "\n";
 
-        $writer = new AtomicWriter(\WCF_DIR . 'lib/bootstrap.php');
+        $writer = new AtomicWriter(WCF::BOOTSTRAP_LOADER);
         $writer->write($result);
         $writer->flush();
+
+        WCF::resetZendOpcache(WCF::BOOTSTRAP_LOADER);
     }
 
     private function bootstrapExists(Package $package): bool