WordPress error under PHP 7.1-7.3 when importing RSS feed

Copyright © 2019 — Creative Commons Attribution-NonCommercial 4.0 International License

There's a nasty bug in WordPress (v 5.2 and below) affecting RSS feed imports, if your site is running PHP v 7.1 or higher. It doesn't show up for all feeds, so you may or may not see it. It does affect YouTube RSS feeds specifically.

In the spot where your RSS feed is supposed to be displayed, you'll see this message:

Warning: A non-numeric value encountered in [mysite]/wp-includes/SimplePie/Parse/Date.php on line 694

Ugly! This affects many (maybe all?) RSS-related plugins, because they all use a WordPress library called SimplePie. There's a small bug in how SimplePie parses dates, but PHP 7.0 and earlier silently ignored it. Starting in PHP 7.1, you get a warning message.

This bug was fixed in April 2016 in SimplePie, but unfortunately WordPress has not managed to upgrade their SimplePie version for various arcane reasons. Details are in this ticket: #36669 - Update SimplePie to Latest Version and possibly include PHP-MF2

The important errors are all in a couple of lines of code in Date.php, so you could fix it yourself by hand-editing that file. Unfortunately you'd have to repeat the edit every time you update WordPress.

But! To the rescue from Tokyo comes Michael Uno, with this simple and excellent WordPress plugin: _fix-simplepie-errors

It provides a bug-fixed Date.php and redirects all calls to the fixed version. Just download the .zip file from GitHub, go to Dashboard > Plugins > Add New > Upload Plugin, upload it, and activate it. (It won't activate unless you are already running PHP 7.1 or higher.) Problem solved!