Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Cache configuration values merged not overwritten
  • Hello. I just ran into a problem where my cache config (using memcached) was picking up extraneous cache values. I'd copied the cache.php file to my application's config dir and modified it for my server values. However, I kept getting a "127.0.0.1" entry in there. It turns out this was coming from the cache config file in fuel's core config directory. Now, I want to be able to easily upgrade fuel as new versions are released so I don't want to modify anything inside the core directory. I was able to work around this by adding the line: \Config::load('cache', true, true, true); before any calls to the cache class. This causes the cache config to load and for the array values in config to not be merged. Later, when the cache class loads the config class will see that this config file is already loaded so won't try to load it again. This works for the moment but seems like a hack. Is there another solution that I haven't found? Is there a reason why the default config load behavior for cache would be to merge?
  • Configuration files merge by default, which allows you to only override the defaults in your app config file. It also makes sure that if you miss any required keys, FuelPHP can fall back on the defaults in core. There was indeed an issue with the cache config, but I remember it was fixed some time ago. Perhaps you're on a version that doesn't have the fix yet? In core/config/cache.php should read:
    'servers' => array( // array of servers and portnumbers that run the memcached service
        'default' => array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100)
    ),
    
    instead of
    'servers' => array( // array of servers and portnumbers that run the memcached service
        array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100)
    ),
    
  • Thank you for the quick response. I'm running v1.2.1 and my core/config/cache.php is the latter form you mention. There is no 'default' subentry in mine. Looking at github it looks like this was changed two weeks ago for the 1.3 release. For now I'll just put a TODO in my code to revisit this when 1.3 is released. Thanks again. -Rick

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion