Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Cache::set doesn't completely clear original value ('file' driver)
  • When using 'file' Cache, the set function doesn't seem to completely overwrite an existing value if the original value is longer than the new value. i.e. If the new value is 10 characters, the set function only replaces the first 10 characters. Observe the consoling:
    >>> Cache::set('key', "I am a meat popsicle.")
    >>> Cache::get('key')
    I am a meat popsicle.
    >>> Cache::set('key', "Who wants a")
    >>> Cache::get('key')
    Who wants a popsicle.
    
    I can't imagine why this would be a feature, so I assume it's a bug. My workaround is to call Cache::delete before issuing any Cache::set, but that seems like a needless added expense, no?
  • Found the bug. The cache file driver does a
    $handle = fopen($file, 'c');
    
    which doesn't truncate the file, that should have been 'w'. I'll commit a fix for 1.2/develop and 1.3/develop. Could you create an issue on github (http://github.com/fuel/core/issues) next time, we don't use the forums for bug reports?
  • Will do. Thanks, Harro.

Howdy, Stranger!

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

In this Discussion