Migrating a WordPress website from PHP 7.4 to PHP 8.3.6

After updated my WordPress to 6.7.1 and added the following to wp-config.php

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

and got the following error message:

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

./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 = 'twentyeleven' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'twentyeleven' WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = 'Twenty Eleven' WHERE option_name = 'current_theme';

But it did not help. I did small research a finally fixed this by commenting SUNRISE define out:

// sunrise.php, it is a drop-in file
// define( 'SUNRISE', 'on' );

This crash happens when both SUNRISE and WP_DEBUG are true.

After that I fixed my Star theme by replacing

	create_function(
		'$css',
		'return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css);'
		)

with

function($css) { return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css); });

PHP 8 still shows the following warnings:

Notice: Function wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the vue-contact-form-style handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function is_feed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the post-password-token-sidebar handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the post-password-token-sidebar handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the jquery handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the custom_script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the custom_script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Deprecated: Function add_custom_image_header is deprecated since version 3.4.0! Use add_theme_support( 'custom-header', $args ) instead. in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function register_sidebar was called incorrectly. No id was set in the arguments array for the "Right_Widgetarea" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Deprecated: Function add_custom_background is deprecated since version 3.4.0! Use add_theme_support( 'custom-background', $args ) instead. in /home/devnote/www/wp-includes/functions.php on line 6114

PHP 7.4 shown the following:

Notice: Function wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the vue-contact-form-style handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function is_feed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the post-password-token-sidebar handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the post-password-token-sidebar handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the jquery handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the custom_script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the custom_script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Deprecated: Function add_custom_image_header is deprecated since version 3.4.0! Use add_theme_support( 'custom-header', $args ) instead. in /home/devnote/www/wp-includes/functions.php on line 6114

Notice: Function register_sidebar was called incorrectly. No id was set in the arguments array for the "Right_Widgetarea" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /home/devnote/www/wp-includes/functions.php on line 6114

Deprecated: Function create_function() is deprecated in /home/devnote/www/wp-content/themes/star/functions.php on line 271

Deprecated: Function add_custom_background is deprecated since version 3.4.0! Use add_theme_support( 'custom-background', $args ) instead. in /home/devnote/www/wp-includes/functions.php on line 6114

I do not need PHP 7.4 anymore.

5 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’;

  2. superadmin says:

    replacing create_function() with something else for PHP8 [duplicate]
    https://stackoverflow.com/questions/72810169/replacing-create-function-with-something-else-for-php8

  3. superadmin says:

    https://developer.wordpress.org/advanced-administration/multisite/domain-mapping/
    Before WordPress 4.5, domain mapping requires a domain mapping plugin like WordPress MU Domain Mapping.
    In WordPress 4.5+, domain mapping is a native feature.

Leave a Reply

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