PHP deprecated: “Automatic conversion of false to array is deprecated”
-
1 year and 5 months after the Updated code post, the plugin YASR – Yet Another Star Rating Plugin for WordPress is still logging PHP deprecation warnings:
[14-May-2026 13:31:37 UTC] PHP Deprecated: Automatic conversion of false to array is deprecated in /home/munged/domains/saotn.org/public_html/wp-content/plugins/yet-another-stars-rating/includes/yasr-includes-functions.php on line 337
[14-May-2026 13:31:38 UTC] PHP Deprecated: Automatic conversion of false to array is deprecated in /home/munged/domains/saotn.org/public_html/wp-content/plugins/yet-another-stars-rating/includes/yasr-includes-functions.php on line 337The GitHub repo you refer to in your “Read this” post doesn’t exist anymore. Too bad you handle this so badly, I sure won’t pay for your (otherwise great working) plugin now.
Here is a fixed function
yasr_getimagesizefor you:function yasr_getimagesize($url) {
//check if url is valid
if (yasr_check_valid_url($url) === true) {
$image_size = @getimagesize($url);
//be sure that getimagesize has returned an array
if (!is_array($image_size)) {
$image_size = array(0, 0);
}
return $image_size;
}
return array(0,0);
}The error occurs because
getimagesize($url)returns the valuefalseif it cannot find a valid image.In older PHP versions, you were allowed to silently override a
falsevalue by using it as an array ($image_size[0] = 0;). However, as of PHP 8.1, this automatic conversion (autovivification) is deprecated, and in PHP 9.0, this will even result in a fatal error.Regards,
Jan
You must be logged in to reply to this topic.