Question:
How to correct WordPress site errors after upgrading to PHP 8.2?

Problem:

I tried to update the PHP of my site on WHM from PHP 7.4 to PHP 8.2.

But before updating I make sure that themes, plugins, and core WordPress are up to date.


After upgrading to PHP 8.2 I've got this error:

  Fatal error: Uncaught TypeError: call_user_func_array():

    Argument #1 ($callback) must be a valid callback, 

    non-static method wp_meta_robots_plugin::meta_robots_addcolumn() 

    cannot be called statically in 

     /home/fixmywri/public_html/wp-includes/class-wp-hook.php:310 

Stack trace: #0 /home/fixmywri/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array)

 #1 /home/fixmywri/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)

 #2 /home/fixmywri/public_html/wp-settings.php(632): do_action('init')

 #3 /home/fixmywri/public_html/wp-config.php(90): require_once('/home/fixmywri/...')

 #4 /home/fixmywri/public_html/wp-load.php(50): require_once('/home/fixmywri/...')

 #5 /home/fixmywri/public_html/wp-blog-header.php(13): require_once('/home/fixmywri/...')

 #6 /home/fixmywri/public_html/index.php(17): require('/home/fixmywri/...')

 #7 {main} thrown in /home/fixmywri/public_html/wp-includes/class-wp-hook.php on line 310


I am using the Twenty Twenty theme. I tried to switch to a different theme, but the error still persists.


What could be the problem with this?


Solution 1: 

Your site contains a plugin called WordPress Meta Robots that hasn't been cleaned up to comply with recent versions of php. The php developers are cleaning up the language to make it more secure, and they've prevented certain operations like the one that caused your error.

How do I know this? I looked at the first couple of lines of your error message where it says


Fatal error: Uncaught TypeError: call_user_func_array():

    Argument #1 ($callback) must be a valid callback, 

    non-static method wp_meta_robots_plugin::meta_robots_addcolumn() 

    cannot be called statically in 

     /home/fixmywri/public_html/wp-includes/class-wp-hook.php:310



Then I used >https://wpdirectory.net/ to search the plugin repo's source code for meta_robots_addcolumn and boom, there it was. A nonstatic method is called as if it were static.

Get rid of the plugin, or get the developer to bring it into compliance, or rollback php to an earlier version, or fix it yourself.


Answered by: >O. Jones

Credit: >Stackoverflow


Solution 2: 

>Currently WordPress only fully supports PHP 7.4, and it only supports with exceptions PHP 8.0 & 8.1, and PHP 8.2 is only in BETA (ie not fully supported for production).

Your error: it leads me to believe that you haven't updated to WordPress 6.3 yet -- which you should do before updating PHP. Fortunately, the latest version of WordPress 6.3.1 fully supports PHP 7.4 -- start with the >detailed Upgrading WordPress Documentation -- as part of that process, you'll also go through and update your plug-ins.

After that, you'll look to upgrade your PHP from 7.4 to 8.2 -- but be prepared it is possible your plugins might not support PHP 8.2.

P.S. Your theme should work fine with 8.2 as I have that running on a test website running on PHP 8.2 -- and the error does not suggest that this is a plugin issue.


Answered by: >Jason Olson

Credit: >Stackoverflow


Suggested Blogs:

>How to create a One Page App with Angular.js, Node.js and MongoDB?

>Complete guide to Perform crud operation in angular using modal popup

>What is data binding in Angular?

>How To Create Nested Table Structure In Angular?


Ritu Singh

Ritu Singh

Submit
0 Answers