'

WordPress makes it easy to graphically create content on pages, but sometimes you have to succumb into the coding side. So I thought that I would share a quick fix for a bug that causes a persistent error in the error log. See the exact error below:

[01-Nov-2019 18:41:33 UTC]PHP Warning: A non-numeric value encountered in /public_html/wp-includes/Sim
p[01-Nov-2019 18:41:33 UTC]lePie/Parse/Date.php on line 694 PHP Warning: A non-numeric value encountere
d[01-Nov-2019 18:47:35 UTC] in /public_html public_html/wp-includes/SimplePie/Parse/Date.php on line 694
[01-Nov-2019 18:47:35 UTC] PHP Warning: A non-numeric value encountered in /public_html/wp-includes/Sim
p[01-Nov-2019 18:47:35 UTC]lePie/Parse/Date.php on line 694 PHP Warning: A non-numeric value encountere
d[01-Nov-2019 18:47:35 UTC] in /public_html public_html/wp-includes/SimplePie/Parse/Date.php on line 694

WordPress error_log

As you can see, the error is constantly on and it can even cause multiple entries within the same second. This can’t be too good for performance or SEO so let’s get started (or wrap up sleeves).

According the the error, there is some non-numeric (maybe strings) values where the code expects numbers (integer = int). If you navigate to the source of this error (date.php line 694), you find out that this error is caused by a line of code that apparently changes time units. Furthermore, the error is caused by incorrect variable types, as said earlier, and it can be corrected by simply casting the variables into integers (int-type). Next, the wrong original line is presented first followed by the corrected line of code.

$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));

As the previous lines showed, the bug is easily fixed by casting match[6] match math[7] variables to integers. The address to the file to be fixed is public_html/wp-includes/SimplePie/Parse/Date.php on a line 694 and you can get there via the C-panel. Here are some Instructions how to open file manager in C-panel (but it is on Finnish). To perform the needed edit directly in c-panel file manager, you need to navigate to that file (Date.php) and select edit at the top of the file manager. Then just navigate to the right line and cast some integers as discussed earlier. The error and its solution can also be found in WordPress Core.

In conclusion, it’s not a bad idea to make it to a habit to read the error log every now and then to get an idea of any errors that might be affecting your site. Many mistakes are easy to correct when you just dare to take up the issue. The most important thing is to detect errors in time and find help on Google, for example. I hope that you find this post helpful.

Jussi


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *