We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Simple Plugin Works On One Server, But Not The Other

Development and Programming

Mike's avatar
Mike
7 posts
6 years ago
Mike's avatar Mike

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

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
6 years ago
Kevin Cupp's avatar Kevin Cupp

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.

       
Mike's avatar
Mike
7 posts
6 years ago
Mike's avatar Mike

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]] = '&#x' . $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;

 }
       
Kevin Cupp's avatar
Kevin Cupp
791 posts
6 years ago
Kevin Cupp's avatar Kevin Cupp

A lot of hosts disable file_get_contents for remote URLs, you might want to see what the status of allow_url_fopen is in your PHP configuration.

       
Mike's avatar
Mike
7 posts
6 years ago
Mike's avatar Mike

Kevin, you are awesome! That was the issue.

Have a fantastic day, tomorrow, and weekend.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.