diff --git a/lib/base.php b/lib/base.php index 055cc6786f02e..47ee2b262ba26 100644 --- a/lib/base.php +++ b/lib/base.php @@ -990,10 +990,10 @@ public static function handleRequest() { self::checkMaintenanceMode($systemConfig); if (\OCP\Util::needUpgrade()) { - if (function_exists('opcache_reset')) { - opcache_reset(); - } if (!((bool) $systemConfig->getValue('maintenance', false))) { + if (function_exists('opcache_reset')) { + opcache_reset(); + } self::printUpgradePage($systemConfig); exit(); } diff --git a/lib/private/Config.php b/lib/private/Config.php index e338d3f2332b2..48ca3d3dc7936 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -59,6 +59,8 @@ class Config { protected $configFileName; /** @var bool */ protected $isReadOnly; + /** @var int */ + protected $lastChecksum; /** * @param string $configDir Path to the config dir, needs to end with '/' @@ -155,7 +157,7 @@ public function setValue($key, $value) { protected function set($key, $value) { $this->checkReadOnly(); - if (!isset($this->cache[$key]) || $this->cache[$key] !== $value) { + if (!isset($this->cache[$key]) || $this->cache[$key] != $value) { // Add change $this->cache[$key] = $value; return true; @@ -259,10 +261,23 @@ private function writeData() { throw new HintException(sprintf('Configuration was not read or initialized correctly, not overwriting %s', $this->configFilePath)); } + /* This creates a checksum of the config file in memory. + * The config file opcache code is only invalidated if the + * config file data has been changed therefore all the other + * code that depend on the the config file opcode will not + * be recompiled. */ + $data = var_export($this->cache, true); + $currentChecksum = crc32($data); + + if ($this->getLastChecksum() == $currentChecksum) + return; + + $this->lastChecksum = $currentChecksum; + // Create a php file ... $content = "cache, true); + $content .= $data; $content .= ";\n"; // tmpfile must be in the same filesystem for the rename() to be atomic @@ -316,4 +331,12 @@ private function checkReadOnly(): void { 'Unset "config_is_read_only" to allow changes to the config file.'); } } + + private function getLastChecksum(): int { + if ($this->lastChecksum == null) { + $data = file_get_contents($this->configFilePath); + $this->lastChecksum = crc32($data); + } + return $this->lastChecksum; + } }