Comprehensive sitemaps for your WordPress VIP site. Joint collaboration between Metro.co.uk, WordPress VIP, Alley Interactive, Maker Media, 10up, and others.
73
stars
37
forks
source link
PHP 8.1: Fatal error, when 'post_date' is '0000-00-00 00:00:00' #171
Due to lack of check for zero date, function 'get_post_year_range' returns range [0,2022].
After that function 'check_year_has_posts' returns [22,2022] and this is how we are getting date '22-11-18'.
Suggested fix:
$oldest_post_date_year = $wpdb->get_var( "SELECT DISTINCT YEAR(post_date) as year FROM $wpdb->posts WHERE post_status = 'publish' AND post_date > 0 ORDER BY year ASC LIMIT 1" );
Hi there,
If a published post of any type has 'post_date' equals to '0000-00-00 00:00:00', on PHP 8.1, when generating sitemap, fatal error will be thrown.
The problem in this SQL query.
Due to lack of check for zero date, function 'get_post_year_range' returns range [0,2022]. After that function 'check_year_has_posts' returns [22,2022] and this is how we are getting date '22-11-18'.
Suggested fix:
I hope, you will find time, to fix this.
Thank you.