Good evening!
We have two environments on different servers – a staging environment and a production environment. For whatever reason, a very simple addon that we’re using is not working on our prod environment. In debugging the PHP, I have found that the following line is treated differently by both
if (ee()->cache->get(‘/’.self::MYNAMESPACE.’/options’) !== FALSE)
The staging server correctly returns an array. The prod server, however, returns emptyness.
I’m guessing this might be a server issue so there could perhaps be a tweak necessary. Does anyone know what that might be?
Thank you
Sorry for your trouble, Mike. Do you mean to say the call to cache->get()
should return an array? If so, I’d check and see if the cached item is actually there and that its contents are what you expect. You should be able to do this by manually probing the caching driver of your choice. For instance, if you’re using the File driver, you can look around in your cache folder to see cached items and their contents.
Hi Kevin,
Thank you for the quick reply! On my staging server, I can see that the cached files are being created. This doesn’t happen on prod though, and unfortunately the problem doesn’t get solved by changing the caching driver (or even disabling it).
Actually, the issue may be that the addon never gets to reach that point. Below is the full function.
Prod goes passed the caching stage (even if I manually add the cached file from the staging server to it). Could it be some sort of webspace issue? This is on EE 4.3 Multi Site, and the setup is something like this:
website1 website2 mainsite systemfolder
This particularly server seems somewhat locked down by default, as I had to request fileinfo be enabled (though, oddly enough, phpinfo() still shows the –disabled flag on it despite it solving a separate upload issue).
function _fa_options()
{
// cache hit?
if (ee()->cache->get('/'.self::MYNAMESPACE.'/options') !== FALSE)
{
return ee()->cache->get('/'.self::MYNAMESPACE.'/options');
}
$fa_options = array();
// get Font Awesome CSS
$fa_css = file_get_contents($this->settings['fa_source']);
// parse Font Awesome CSS
if ($fa_css !== FALSE) {
$heart_of_gold = '/\.(fa-[_a-zA-Z0-9-]*?):before\s*\{\s*content:\s*".(f...)"/';
preg_match_all($heart_of_gold, $fa_css, $matches, PREG_SET_ORDER);
// properly format options array
foreach ($matches as $match) {
$fa_options[$match[1]] = '' . $match[2] . ' ' . ucfirst(substr($match[1], 3));
}
ksort($fa_options);
}
if (count($fa_options) > 100) // some light data validation
{
ee()->cache->save('/'.self::MYNAMESPACE.'/options', $fa_options, self::CACHE_TTL);
}
return $fa_options;
}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.