From f7ac93cf4fe5eb39c8c42f8d36263b84eb97388e Mon Sep 17 00:00:00 2001 From: Adrien Date: Mon, 24 Feb 2025 14:34:35 +0100 Subject: [PATCH] Remove Config::sanityCheck method as it doesn't make sense --- core/Config.php | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/core/Config.php b/core/Config.php index e17ff3d6bea..71fd2360a47 100644 --- a/core/Config.php +++ b/core/Config.php @@ -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(); /** @@ -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; - } }