Config.ini.php gets written on every request?


(blueyed) #1

It looks like config/config.ini.php gets rewritten on every page request, probably through the call of “forceSave” in Piwik_Config::__destruct.

While the documentation says “At the script shutdown, we save the new configuration file, if the user has set some values” it seems like forceSave does it unconditionally.

Apart from that I suggest that dumpConfig should sort the generated config, to make sure that sections do not jump around in the config file when the same config gets re-saved.


(Matthieu Aubry) #2

I assume you’re using trunk. please post your feedback in Config class refactoring · Issue #1713 · matomo-org/matomo · GitHub


(vipsoft) #3

this should now be fixed in trunk; unifying two different config class implementations was trickier than I originally contemplated =P

but I still believe this was worth the effort to get rid of:


if(!empty($GLOBALS['PIWIK_TRACKER_MODE']))
{
    $hashAlgorithm = @Piwik_Tracker_Config::getInstance()->General['hash_algorithm'];
}
else
{
    $config = Zend_Registry::get('config');
    if($config !== false)
    {
        $hashAlgorithm = @$config->General->hash_algorithm;
    }
}

and replace it with:


$hashAlgorithm = @Piwik_Config::getInstance()->General['hash_algorithm'];


(Matthieu Aubry) #4

Definitely, great work :slight_smile: