admin管理员组

文章数量:1318572

I migrated my WordPress (multisite) website from PHP 7.4 to PHP 8.3.6 and got the following error:

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:

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

Where can this error come from?

I disabled the plugins and changed the theme, see here for details, but it did not help.

WordPress version is 6.7.1 (latest).

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

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 screenshot of my Multisite Admin panel:

I migrated my WordPress (multisite) website from PHP 7.4 to PHP 8.3.6 and got the following error:

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:

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

Where can this error come from?

I disabled the plugins and changed the theme, see here for details, but it did not help.

WordPress version is 6.7.1 (latest).

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

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 screenshot of my Multisite Admin panel:

Share Improve this question edited Jan 21 at 13:27 hakre 198k55 gold badges447 silver badges855 bronze badges Recognized by PHP Collective asked Jan 21 at 10:58 DmitrianoDmitriano 2,06015 silver badges48 bronze badges 12
  • 1 How did you migrate the code? wp_kses is not a function offered by PHP 7 or 8 – Nico Haase Commented Jan 21 at 11:04
  • 4 The function should be located in wp-includes/kses.php, but I could not tell you whether that has already been included when the code in functions.php executes. (You could try to embed it yourself in there using require_once, and see if that changes things.) But a mere switch of the PHP version should not have caused this error. – C3roe Commented Jan 21 at 11:06
  • 2 The sunrise.php file is out of date. It must not call wpdb->escape() in line 11. And disable the opcache until you get it running. – hakre Commented Jan 21 at 11:24
  • 1 @Dmitriano: Just check sunrise.php, it is a drop-in file and you have configured WP to include it for MU setup. That means you have to take care to update it yourself. The configuration switch is the SUNRISE constant. Undefine it and test if everything already works. The constant controls if the file is included or not. Start with that. – hakre Commented Jan 21 at 13:11
  • 1 Comment out the define, do not set it to "off" or similar, see: core.trac.wordpress./ticket/20220 – hakre Commented Jan 21 at 13:15
 |  Show 7 more comments

1 Answer 1

Reset to default 2

You have an old sunrise.php file left over in the wp-content/ folder.

It is a drop-in file (compare with Must-Use Plugins and Drop-Ins on my blog).

And it gets included if the constant named SUNRISE is defined.

Check your ./wp-config.php file if it is defined there (or otherwise search the string in PHP files) and uncomment the line.

This then will prevent the drop-in from being loaded and most likely things will work again. If the operations in the file are actually required for your multi-site setup, you have to update the code there in and replace deprecated functionality. But probably it is just an oversight since some version 3 of the installation.

本文标签: wordpressUncaught Error Call to undefined function wpkses() with PHP 836Stack Overflow