10000 Remove Config::sanityCheck method as it doesn't make sense by Bacto · Pull Request #23066 · matomo-org/matomo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove Config::sanityCheck method as it doesn't make sense #23066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 5.x-dev
Choose a base branch
from
Open
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
41 changes: 0 additions & 41 deletions core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,6 @@ protected function writeConfig()
throw $this->getConfigNotWritableException();
}

if (!$this->sanityCheck($localPath, $output)) {
// If sanity check fails, try to write the contents once more before logging the issue.
if (@file_put_contents($localPath, $output, LOCK_EX) === false || !$this->sanityCheck($localPath, $output, true)) {
StaticContainer::get(LoggerInterface::class)->info("The configuration file {$localPath} did not write correctly.");
}
}

$this->settings->getIniFileChain()->deleteConfigCache();

/**
Expand Down Expand Up @@ -475,38 +468,4 @@ public static function setSetting($sectionName, $name, $value)
$section[$name] = $value;
self::getInstance()->$sectionName = $section;
}

/**
* Sanity check a config file by checking contents
*
* @param string $localPath
* @param string $expectedContent
* @param bool $notify
* @return bool
*/
public function sanityCheck(string $localPath, string $expectedContent, bool $notify = false): bool
{
clearstatcache(true, $localPath);

if (function_exists('opcache_invalidate')) {
@opcache_invalidate($localPath, $force = true);
}

$content = @file_get_contents($localPath);

if (trim($content) !== trim($expectedContent)) {
if ($notify) {
/**
* Triggered when the INI config file was not written correctly with the expected content.
*
* @param string $localPath Absolute path to the changed file on the server.
*/
Piwik::postEvent('Core.configFileSanityCheckFailed', [$localPath]);
}

return false;
}

return true;
}
}
0