Bug fix for cache and custom helpers

Permalink
I've got lots of custom helpers, as well as overrides of core helpers for a site I'm working on. However, whenever I turned on the cache, C5 would crash. I traced it to the Loader::helper() method. Apparently this method gets called when unserializing objects from the cache. When my site helpers were being unserialized, C5 was looking for a class called 'site_form' instead of 'form' in the site folder. Adding the following to line 202 of /root/concrete/libraries/loader.php fixes the problem:

$file = preg_replace('/^site_/', '', $file);

I haven't tested extensively, but it seems to be working OK right now.

The only thing it might disrupt is overidden helpers in packages (since the package name gets stuck at the front, and that regex doesn't expect anything before 'site_'). Maybe the core team can figure out exactly what this should be.

 
andrew replied on at Permalink Reply
andrew
This is helpful. I can see why this would happen. I'll add this to startup/autoload.php in the core:

Change this:

$class = substr($class, 0, strpos($class, 'Helper'));
$handle = $txt->uncamelcase($class);
Loader::helper($handle);


to this

$class = substr($class, 0, strpos($class, 'Helper'));
$handle = $txt->uncamelcase($class);
$handle = preg_replace('/^site_/', '', $handle);
Loader::helper($handle);


I would think that should do it.