[ad_1]
I have some sites still on PHP 7.2, and version 5.1 introduced the following site-wide fatal server error:Parse error: syntax error, unexpected ')' in /wp-content/plugins/shortpixel-image-optimiser/class/Controller/AdminNoticesController.php on line 226
The code in question is:
$message = sprintf(__('%s With ShortPixel you can now %ssmartly crop%s the thumbnails on your website. This is especially useful for eCommerce websites %s(read more)%s. %s %s Activate the option in the %sShortPixel Settings%s page. %s', 'shortpixel-image-optimiser'),
'<p>' ,
'<a href="' . $link . '" target="_blank">', '</a>',
'<a href="' . $link2 . '" target="_blank">', '</a>',
'</p>', '<p>',
'<a href="' . $link3 . '" >', '</a>',
'</p>',
);
when it should be:
$message = sprintf(__('%s With ShortPixel you can now %ssmartly crop%s the thumbnails on your website. This is especially useful for eCommerce websites %s(read more)%s. %s %s Activate the option in the %sShortPixel Settings%s page. %s', 'shortpixel-image-optimiser'),
'<p>' ,
'<a href="' . $link . '" target="_blank">', '</a>',
'<a href="' . $link2 . '" target="_blank">', '</a>',
'</p>', '<p>',
'<a href="' . $link3 . '" >', '</a>',
'</p>'
);
The primary issue is the fact that there’s a trailing comma at the end of a function’s list of attributes (which PHP 7.2 doesn’t like) where '</p>', in the code above needs to become '</p>'. Trailing commas are okay for arrays & things, but it’s problematic when at the end of a function’s parameters.
Thankfully, making this one update appears to resolve the site-wide 500 internal server error (there might be others like this [haven’t dug in to confirm yet], but at least it doesn’t take down the whole site after this change is made.)
This plugin says it supports PHP 5.6 so either that needs to be updated to 7.3 or this quick fix needs to be applied (then avoiding this in the future to avoid sites with 7.2 going offline due to a problematic update.)
