Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
27 changes: 25 additions & 2 deletions lib/private/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '/'
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Check failure

Code scanning / Psalm

TaintedHtml

Detected tainted HTML

Check failure

Code scanning / Psalm

TaintedHtml

Detected tainted HTML
$currentChecksum = crc32($data);

if ($this->getLastChecksum() == $currentChecksum)
return;

$this->lastChecksum = $currentChecksum;

// Create a php file ...
$content = "<?php\n";
$content .= '$CONFIG = ';
$content .= var_export($this->cache, true);
$content .= $data;
$content .= ";\n";

// tmpfile must be in the same filesystem for the rename() to be atomic
Expand Down Expand Up @@ -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;
}
}