Migrating a WordPress website from PHP 7.4 to PHP 8.3.6

Added the following

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

to wp-config.php and got the following error message:

Fatal error: Uncaught Error: Call to undefined function wp_kses() in /home/devnote/www/wp-includes/functions.php:6073 
Stack trace:
#0 /home/devnote/www/wp-includes/functions.php(5554): wp_trigger_error()
#1 /home/devnote/www/wp-includes/class-wpdb.php(1333): _deprecated_function()
#2 /home/devnote/www/wp-content/sunrise.php(11): wpdb->escape()
#3 /home/devnote/www/wp-includes/ms-settings.php(47): include_once('...')
#4 /home/devnote/www/wp-settings.php(155): require('...')
#5 /home/devnote/www/wp-config.php(107): require_once('...')
#6 /home/devnote/www/wp-load.php(50): require_once('...')
#7 /home/devnote/www/wp-blog-header.php(13): require_once('...')
#8 /home/devnote/www/index.php(17): require('...')
#9 {main} thrown in /home/devnote/www/wp-includes/functions.php on line 6073

./wp-includes/functions.php:

head -6090 ./wp-includes/functions.php | tail -24
        do_action( 'wp_trigger_error_run', $function_name, $message, $error_level );

        if ( ! empty( $function_name ) ) {
                $message = sprintf( '%s(): %s', $function_name, $message );
        }

        $message = wp_kses(
                $message,
                array(
                        'a'      => array( 'href' => true ),
                        'br'     => array(),
                        'code'   => array(),
                        'em'     => array(),
                        'strong' => array(),
                ),
                array( 'http', 'https' )
        );

        trigger_error( $message, $error_level );

Disabled all the plugins:

mysql> select * from wp_options where option_name='active_plugins';
+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+
| option_id | option_name    | option_value                                                                                                                                                                                                | autoload |
+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+
|        36 | active_plugins | a:4:{i:0;s:29:"advanced-ads/advanced-ads.php";i:1;s:44:"post-password-plugin/post-password-token.php";i:2;s:39:"syntaxhighlighter/syntaxhighlighter.php";i:3;s:37:"vue-contact-form/vue-contact-form.php";} | yes      |
+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+
1 row in set (0.00 sec)

mysql> update wp_options set option_value='a:0:{}' where option_name='active_plugins';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

And changed the theme:

mysql> select * from wp_options where option_name='template';
+-----------+-------------+--------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+--------------+----------+
|        45 | template    | star         | yes      |
+-----------+-------------+--------------+----------+
1 row in set (0.00 sec)

mysql> select * from wp_options where option_name='stylesheet';
+-----------+-------------+--------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+--------------+----------+
|        46 | stylesheet  | star         | yes      |
+-----------+-------------+--------------+----------+
1 row in set (0.00 sec)

mysql> select * from wp_options where option_name='current_theme';
+-----------+---------------+--------------+----------+
| option_id | option_name   | option_value | autoload |
+-----------+---------------+--------------+----------+
|       678 | current_theme | Star         | yes      |
+-----------+---------------+--------------+----------+
1 row in set (0.00 sec)
UPDATE wp_options SET option_value = 'evidens-white' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'evidens-white' WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = 'Evidens [White]' WHERE option_name = 'current_theme';

But it did not help.

After updating the the latest WordPress version 6.7.1 the line numbers changed a bit:

Fatal error: Uncaught Error: Call to undefined function wp_kses() in /home/devnote/www/wp-includes/functions.php:6098 Stack trace: 
#0 /home/devnote/www/wp-includes/functions.php(5579):
wp_trigger_error()
#1 /home/devnote/www/wp-includes/class-wpdb.php(1333): _deprecated_function()
#2 /home/devnote/www/wp-content/sunrise.php(11): wpdb->escape()
#3 /home/devnote/www/wp-includes/ms-settings.php(47): include_once('...')
#4 /home/devnote/www/wp-settings.php(156): require('...')
#5 /home/devnote/www/wp-config.php(107): require_once('...')
#6 /home/devnote/www/wp-load.php(50): require_once('...')
#7 /home/devnote/www/wp-blog-header.php(13): require_once('...')
#8 /home/devnote/www/index.php(17): require('...')
#9 {main} thrown in /home/devnote/www/wp-includes/functions.php on line 6098

The next step is probably installing PHP7.4 in a docker container.

2 Responses to Migrating a WordPress website from PHP 7.4 to PHP 8.3.6

  1. superadmin says:

    How to change the active wordpress theme using MySQL command line?
    https://stackoverflow.com/questions/54277428/how-to-change-the-active-wordpress-theme-using-mysql-command-line
    UPDATE wp_options SET option_value = ‘‘ WHERE option_name = ‘template’;
    UPDATE wp_options SET option_value = ‘
    ‘ WHERE option_name = ‘stylesheet’;
    UPDATE wp_options SET option_value = ‘
    ‘ WHERE option_name = ‘current_theme’;

Leave a Reply

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