simple-image-sizes icon indicating copy to clipboard operation
simple-image-sizes copied to clipboard

Version 3.2.1 causes fatal errors on WordPress.com VIP Go host

Open jonathanstegall opened this issue 6 years ago • 9 comments

I upgraded this plugin on my local development server and it seemed fine, but when I pushed it to my staging server (which is hosted on WordPress VIP Go), I got this error:

Error Details
=============
An error of type E_ERROR was caused in line 42 of the file /var/www/wp-content/plugins/simple-image-sizes/simple_image_sizes.php. Error message: Uncaught Error: Class 'Rahe\Simple_Image_Sizes\Main' not found in /var/www/wp-content/plugins/simple-image-sizes/simple_image_sizes.php:42
Stack trace:
#0 /var/www/wp-includes/class-wp-hook.php(286): init_sis('')
#1 /var/www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#2 /var/www/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#3 /var/www/wp-settings.php(394): do_action('plugins_loaded')
#4 /var/www/wp-config.php(11): require_once('/var/www/wp-set...')
#5 /var/www/wp-load.php(37): require_once('/var/www/wp-con...')
#6 /var/www/wp-admin/admin.php(34): require_once('/var/www/wp-loa...')
#7 {main}
  thrown

I've downgraded back to 3.2.0 and it works fine, so I'm not upgrading my production site, but I wanted to mention. It's not clear to me why VIP is unable to find the class. It doesn't generally have issues with composer autoloading, but there may be something specific about how it's being done here.

jonathanstegall avatar May 17 '19 12:05 jonathanstegall

Hello,

Thank you for your report. I just use the autoloader from composer nothing fancy and even i used the optimized one. It seems that the vendor/autoload.php file isn't even called here.

Can you see what's exactly on the server ?

Nicolas,

Rahe avatar May 17 '19 12:05 Rahe

Maybe the file_exists DIR is not working correctly :/

Rahe avatar May 17 '19 12:05 Rahe

I can't really see what is on the server. They do have their own kind of file system infrastructure there, though, and sometimes it can be restrictive. I've noticed this more often when interacting with their CDN, as it has its own methods, but also I think sometimes it can come up in directory issues.

jonathanstegall avatar May 17 '19 12:05 jonathanstegall

[UPDATE] Seems to call autoloader, but still doesn't find the Main class. Error message is: PHP Fatal error: Uncaught Error: Class 'Rahe\Simple_Image_Sizes\Main' not found /nas/content/live/officeninjas/wp-content/plugins/simple-image-sizes/simple_image_sizes.php:56\nStack trace: #0 [internal function]: init_sis('') #1 /nas/content/live/officeninjas/wp-includes/class-wp-hook.php(286): call_user_func_array('init_sis', Array) #2 /nas/content/live/officeninjas/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #3 /nas/content/live/officeninjas/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #4 /nas/content/live/officeninjas/wp-settings.php(394): do_action('plugins_loaded') #5 /nas/content/live/officeninjas/wp-config.php(131): require_once('/nas/content/li...') #6 /nas/content/live/officeninjas/wp-load.php(37): require_once('/nas/content/li...') #7 /nas/content/live/officeninjas/wp-blog-header.php(13): require_once('/nas/content/li...') #8 /nas/content/live/officeninjas/index.php(17): require('/nas/content/li...') #9 {main}\n thrown in /nas/content/live/officeninjas/wp-content/plugins/simple-image-sizes/simple_image_sizes.php on line 56


I'm on WP Engine, upgraded using git push and got the same Fatal Error. Works fine on local, though. Both same PHP 7.2. After some testing it turns out that WP Engine ...

does not allow

file_exists( DIR . '/vendor/autoload.php' );

does allow the following 2 options

$filename = DIR . '/vendor/autoload.php'; file_exists( $filename );

$autoload_path = "/vendor/autoload.php"; file_exists( DIR . $autoload_path );

Not sure why this is the case, but at least it's a simple code modification.

HTH

officeninjas avatar Jun 03 '19 04:06 officeninjas

I'm had the same issue. I found few problems and solutions

  1. When you update the plugin from wordpress the composer.json file was missing.
  2. For autoloading the file name and classname should be the same. I can see the filename is main.php but classname is Main. Rename file name to Main.php
  3. Also make sure rename admin folder to Admin

malithmcr avatar Jun 03 '19 11:06 malithmcr

Hello,

I'm using classmap so I normally will not have issue for the class/files names :/

I will change my code accordingly.

Just to check @jonathanstegall @officeninjas the plugin https://github.com/Rarst/laps is using the same piece of code, do you have problem with it too ?

Rahe avatar Jun 03 '19 15:06 Rahe

I don't use the Laps plugin.

officeninjas avatar Jun 03 '19 15:06 officeninjas

I also don't use the Laps plugin.

jonathanstegall avatar Aug 08 '19 15:08 jonathanstegall

I've just upgraded a site to 3.2.2 and am having this issue with Pantheon staging. Since this issue is still open I'm assuming the fix didn't make it into 3.2.2?

jaiivarsson avatar Sep 07 '23 06:09 jaiivarsson