/** * Reloads config data from disk. * * @throws \Exception if the global config file is not found and this is a tracker request, or * if the local config file is not found and this is NOT a tracker request. */ public function reload() { $this->initialized = true; $inTrackerRequest = SettingsServer::isTrackerApiRequest(); // read defaults from global.ini.php if (!is_readable($this->pathGlobal) && $inTrackerRequest) { throw new Exception(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathGlobal))); } try { $this->settings->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal); } catch (IniReadingException $e) { if ($inTrackerRequest) { throw $e; } } // Check config.ini.php last if (!$inTrackerRequest) { $this->checkLocalConfigFound(); } }
/** * @dataProvider getMergingTestData */ public function test_reload_MergesFileData_Correctly($testDescription, $defaultSettingsFiles, $userSettingsFile, $expected) { $fileChain = new IniFileChain(); $fileChain->reload($defaultSettingsFiles, $userSettingsFile); $this->assertEquals($expected, $fileChain->getAll(), "'{$testDescription}' failed"); }