Smush Pro warnings in debug.log

The following error messages are in debug.log. The plugin is working good.

Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/*******/public/wp-content/plugins/wp-smush-pro/lib/class-wp-smush-admin.php on line 2054

Warning: Cannot modify header information - headers already sent by (output started at /srv/users/serverpilot/apps/*******/public/wp-content/plugins/wp-smush-pro/lib/class-wp-smush-admin.php:2054) in /srv/users/serverpilot/apps/*******/public/wp-includes/option.php on line 919

Warning: Cannot modify header information - headers already sent by (output started at /srv/users/serverpilot/apps/*******/public/wp-content/plugins/wp-smush-pro/lib/class-wp-smush-admin.php:2054) in /srv/users/serverpilot/apps/*******/public/wp-includes/option.php on line 920
  • Predrag Dubajic
    • Support

    Hey Marco,

    Hope you're doing well :slight_smile:

    I tested my installation with same PHP version to see if that could be the issue but I was unable to see any warnings there.

    I see that you talked with Dimitris about creating a staging site where further tests could be performed, did you manage to set it up?

    I've also forwarded these to Smush dev so he can check it out and tell us what might be causing this, so I'm waiting for his feedback as well.

    Best regards,

  • Adam Czajczyk
    • Support Gorilla

    Hello Marco!

    I checked the staging site and I also experienced quite a lot of randomly triggered 503 errors there related to PHP. It looks like the PHP or Apache web server gets "clogged up" intermittently.

    I'm not a server administration specialist so it might be worth checking with your hosts staff or hiring a sys-admin to take a look at the system configuration there, to make sure that it's optimized. However, that's a side note rather than a diagnosis :slight_smile:

    Getting back to the initial issue. The WP Smush Pro seems to be fine in terms of its functionality but there is something that bothers me. Let me explain :slight_smile:

    If you go to "Media -> WP Smush" page you'll notice that it lists only a single image size there. However, if you go to "Settings -> Media" page you'll see all three WP-default (native) image sizes defined there. On the other hand, if you try to add an image to the post, you only got a single size choice and it's none of those listed in two aforementioned locations. Furthermore, if you go to "Media Library", find an image that's been already smushed previously and check smuch stats, you'll notice that there were 4 image sizes that were optimized and actually they're again different to the ones mentioned above.

    That's a weird thing and I would suspect that this might be related here because this line in debug log

    Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/*******/public/wp-content/plugins/wp-smush-pro/lib/class-wp-smush-admin.php on line 2054

    refers to a code in WP Smush Pro which calls out native WP "get_intermediate_image_sizes()" function which is there to... list available file sizes, meaning file sizes registered on your site.
    The error itself suggests that this function actually returns either some error or an empty/null value which in turn breaks the loop that's there and generates the error.

    That being said, I think you're using a child theme on the site, right? I'm wondering if there's been any kind of code added to it to that would somehow manipulate/affect registered image sizes on site?

    Also, did you previously use/test any kind of plugin related to that? Those could be e.g. plugins to change/recreate thumbnails, plugins for supporting retina images etc, basically - any kind of plugins that might affect images in any way?

    Let me know please.

    Kind regards,

  • Marco Andrei
    • WPMU DEV Initiate

    Hello, Adam!

    I'm back.

    1) Working with my infraestructure provider, I increased the server memory, so I think the "503 errors" gone away.

    2) About the child theme: the only modification is not related to any image manipulation (I only tweaked the contact page).

    Please, let me know if you need some other information.

    Marco Andrei

  • Predrag Dubajic
    • Support

    Hi Marco,

    I was doing some additional tests on your site and the issue seems to be theme related as with default WP theme the issue is not there.

    Strange thing that I tested this on two of my local installations, one run by MAMP and other by Local by Flywheel and on MAMP installation there were no issues, while on Flywheel I could see the warnings.
    What's even stranger is that PHP and mySQL versions are almost the same on both installations so I'm not really sure about where the issue is coming from.

    I have forwarded all the info I gathered to our developers so they can check it out, however I would also suggest getting in touch with your theme developers about this so they can check theme code as well and this could speed up finding the solution.

    Best regards,

  • Ari
    • Recruit

    Hey Marco Andrei,

    I'm really sorry to see that you are having trouble with our plugin!

    While i investigate the issue I found that: in your theme, in this file: chronicle-premium/core/customs/image_core.php developer have added few image sizes, the problem He have removed few image sizes conditionally, which is good for a theme, but our plugin wasn't ready to accept this constitutional removing option, that's why the warning was came up.

    Now I fixed it by changing our plugin's core file. you have to replace the old file with the new one. To do so:
    1: Please go to the FTP or cPanel file manager.
    2: Go to this path: wp-content/plugins/wp-smush-pro/lib
    3: Rename the class-wp-smush-admin.php to old-class-wp-smush-admin.php for backup purpose.
    2: Download the attached zip file and upzip it, upload the php file in that path.

    This fix is worked for me, please let me know is that helped you!

    Note: While I investigated the issue, I didn't find the "Cannot modify header information", That's why i'm not sure Is this warning get fixed by this solution or not. If you still see this error, please give me your site WP & FTP access, since it is related only with your hosting, and send them to me using our secure contact from:
    Using the below template:

    Subject: "Attn: Ari"
    - WordPress admin (login url/username/password)
    - FTP credentials (host/username/password)
    - cPanel/Plesk credentials (host/username/password)
    - link back to this thread for reference (it is:

    Keep in mind the subject line as ensures that it gets assigned to me.

    Have a great day!
    Warm Regards,

  • Ari
    • Recruit

    Hey Marco Andrei,

    Thought the above fix is I hope working fine against warnings, but this will not fix the actual issue.
    So I dig in and figure out the cause of the issue, it's a bug in chronicles theme they are not returning sizes value if the post-id is not set in the weblizar_image_presets().

    That's why when our plugin try to smushing with images_sizes, it will not receive the sizes, since the theme didn't return the sizes value.

    This bug could cause lot of issues Like there would be no image sizes listed under "Automatically smush my images on upload" and only the full size image would be resized with chronicles theme being active, so please contact to the theme developer to fix this issue, since it's related to the chronicles theme.

    Best Regards, Ari

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.