没有不值得去解决的问题,也没有不值得去学习的技术!

After Redeploying the WordPress System Disk (PHP 7.4 to PHP 8.1): This Site Encountered a Fatal Error

After redeploying the WordPress system disk, it prompted: There has been a critical error on this website.

1. Reference: Migrating (replacing) CentOS 7 with Alibaba Cloud Linux 3 in Alibaba Cloud ECS. After redeploying the WordPress system disk, it prompted: There has been a critical error on this website. See Figure 1.

After redeploying the WordPress system disk, it prompted: There has been a critical error on this website.
Figure 1

2. Learn more about troubleshooting WordPress. Enable developer-specific: WordPress debug mode. Edit wp-config.php.

PHP
/**
 * 开发者专用:WordPress 调试模式。
 *
 * 将这个值改为“true”,WordPress 将显示所有用于开发的提示。
 * 强烈建议插件开发者在开发环境中启用本功能。
 */
define('WP_DEBUG', true);

3. Refresh the page again, and errors are reported.

Plaintext
Deprecated: Return type of HM\BackUpWordPress\CleanUpIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /data/wwwroot/www.shuijingwanwq.com/wp-content/plugins/backupwordpress/classes/class-path.php on line 456

Fatal error: Uncaught Error: Undefined constant "wp_cumulus_widget" in /data/wwwroot/www.shuijingwanwq.com/wp-content/plugins/wp-cumulus/wp-cumulus.php:375 Stack trace: #0 /data/wwwroot/www.shuijingwanwq.com/wp-includes/class-wp-hook.php(308): widget_init_wp_cumulus_widget() #1 /data/wwwroot/www.shuijingwanwq.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #2 /data/wwwroot/www.shuijingwanwq.com/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /data/wwwroot/www.shuijingwanwq.com/wp-includes/widgets.php(1854): do_action() #4 /data/wwwroot/www.shuijingwanwq.com/wp-includes/class-wp-hook.php(308): wp_widgets_init() #5 /data/wwwroot/www.shuijingwanwq.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #6 /data/wwwroot/www.shuijingwanwq.com/wp-includes/plugin.php(517): WP_Hook->do_action() #7 /data/wwwroot/www.shuijingwanwq.com/wp-settings.php(623): do_action() #8 /data/wwwroot/www.shuijingwanwq.com/wp-config.php(87): require_once('...') #9 /data/wwwroot/www.shuijingwanwq.com/wp-load.php(50): require_once('...') #10 /data/wwwroot/www.shuijingwanwq.com/wp-blog-header.php(13): require_once('...') #11 /data/wwwroot/www.shuijingwanwq.com/index.php(17): require('...') #12 {main} thrown in /data/wwwroot/www.shuijingwanwq.com/wp-content/plugins/wp-cumulus/wp-cumulus.php on line 375

4. I found that all the errors were from plugins, so I decided to find a way to disable the plugins causing the errors first. Since I could not access the WordPress dashboard, I needed to disable the plugins in a different way. Reference: How to Disable WordPress Plugins (4 Methods).

5. Reference: How to Disable WordPress Plugins via phpMyAdmin. Its essence is manipulating data in the database.

6. Back up the database before manipulating the data. Open the wp_options table. See Figure 2.

Back up the database before manipulating the data. Open the wp_options table
Figure 2

7. In the options table, look for the active_plugins entry in the option_name column. Execute the following SQL query. See Figure 3.

In the options table, look for the active_plugins entry in the option_name column. Execute the following SQL query
Figure 3
SQL
SELECT * FROM `wp_options` WHERE `option_name` = 'active_plugins'

8. Copy the value of the option_value column from the query result record, and use an online PHP deserialization tool.

Plaintext

a:14:{i:0;s:53:"accelerated-mobile-pages/accelerated-moblie-pages.php";i:1;s:19:"akismet/akismet.php";i:2;s:35:"backupwordpress/backupwordpress.php";i:3;s:33:"classic-editor/classic-editor.php";i:4;s:36:"contact-form-7/wp-contact-form-7.php";i:5;s:45:"disable-google-fonts/disable-google-fonts.php";i:6;s:72:"golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php";i:7;s:25:"hueman-addons/ha-fire.php";i:8;s:15:"light/light.php";i:9;s:33:"nimble-builder/nimble-builder.php";i:10;s:47:"regenerate-thumbnails/regenerate-thumbnails.php";i:11;s:39:"syntaxhighlighter/syntaxhighlighter.php";i:12;s:25:"wp-cumulus/wp-cumulus.php";i:13;s:27:"wp-pagenavi/wp-pagenavi.php";}


Array
(
    [0] => accelerated-mobile-pages/accelerated-moblie-pages.php
    [1] => akismet/akismet.php
    [2] => backupwordpress/backupwordpress.php
    [3] => classic-editor/classic-editor.php
    [4] => contact-form-7/wp-contact-form-7.php
    [5] => disable-google-fonts/disable-google-fonts.php
    [6] => golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php
    [7] => hueman-addons/ha-fire.php
    [8] => light/light.php
    [9] => nimble-builder/nimble-builder.php
    [10] => regenerate-thumbnails/regenerate-thumbnails.php
    [11] => syntaxhighlighter/syntaxhighlighter.php
    [12] => wp-cumulus/wp-cumulus.php
    [13] => wp-pagenavi/wp-pagenavi.php
)

9. Remove the plugins backupwordpress/backupwordpress.php and wp-cumulus/wp-cumulus.php from the deserialized result, then store the PHP serialized result back into the value of the option_value column. The PHP code implementation is as follows.

PHP
<?php
$a = 'a:14:{i:0;s:53:"accelerated-mobile-pages/accelerated-moblie-pages.php";i:1;s:19:"akismet/akismet.php";i:2;s:35:"backupwordpress/backupwordpress.php";i:3;s:33:"classic-editor/classic-editor.php";i:4;s:36:"contact-form-7/wp-contact-form-7.php";i:5;s:45:"disable-google-fonts/disable-google-fonts.php";i:6;s:72:"golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php";i:7;s:25:"hueman-addons/ha-fire.php";i:8;s:15:"light/light.php";i:9;s:33:"nimble-builder/nimble-builder.php";i:10;s:47:"regenerate-thumbnails/regenerate-thumbnails.php";i:11;s:39:"syntaxhighlighter/syntaxhighlighter.php";i:12;s:25:"wp-cumulus/wp-cumulus.php";i:13;s:27:"wp-pagenavi/wp-pagenavi.php";}';
$b = unserialize($a);
print_r($b);
$c = [
    'accelerated-mobile-pages/accelerated-moblie-pages.php',
    'akismet/akismet.php',
    'classic-editor/classic-editor.php',
    'contact-form-7/wp-contact-form-7.php',
    'disable-google-fonts/disable-google-fonts.php',
    'golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php',
    'hueman-addons/ha-fire.php',
    'light/light.php',
    'nimble-builder/nimble-builder.php',
    'regenerate-thumbnails/regenerate-thumbnails.php',
    'syntaxhighlighter/syntaxhighlighter.php',
    'wp-pagenavi/wp-pagenavi.php'
];
print_r($c);
$d = serialize($c);
print_r($d);
exit;
?>
Plaintext

Array
(
    [0] => accelerated-mobile-pages/accelerated-moblie-pages.php
    [1] => akismet/akismet.php
    [2] => classic-editor/classic-editor.php
    [3] => contact-form-7/wp-contact-form-7.php
    [4] => disable-google-fonts/disable-google-fonts.php
    [5] => golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php
    [6] => hueman-addons/ha-fire.php
    [7] => light/light.php
    [8] => nimble-builder/nimble-builder.php
    [9] => regenerate-thumbnails/regenerate-thumbnails.php
    [10] => syntaxhighlighter/syntaxhighlighter.php
    [11] => wp-pagenavi/wp-pagenavi.php
)

a:12:{i:0;s:53:"accelerated-mobile-pages/accelerated-moblie-pages.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"classic-editor/classic-editor.php";i:3;s:36:"contact-form-7/wp-contact-form-7.php";i:4;s:45:"disable-google-fonts/disable-google-fonts.php";i:5;s:72:"golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php";i:6;s:25:"hueman-addons/ha-fire.php";i:7;s:15:"light/light.php";i:8;s:33:"nimble-builder/nimble-builder.php";i:9;s:47:"regenerate-thumbnails/regenerate-thumbnails.php";i:10;s:39:"syntaxhighlighter/syntaxhighlighter.php";i:11;s:27:"wp-pagenavi/wp-pagenavi.php";}

SQL
UPDATE `shuijingwanwq`.`wp_options` SET `option_value`='a:12:{i:0;s:53:"accelerated-mobile-pages/accelerated-moblie-pages.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"classic-editor/classic-editor.php";i:3;s:36:"contact-form-7/wp-contact-form-7.php";i:4;s:45:"disable-google-fonts/disable-google-fonts.php";i:5;s:72:"golang-brush-for-syntaxhighlighter-evolved/syntaxhighlighter-GoBrush.php";i:6;s:25:"hueman-addons/ha-fire.php";i:7;s:15:"light/light.php";i:8;s:33:"nimble-builder/nimble-builder.php";i:9;s:47:"regenerate-thumbnails/regenerate-thumbnails.php";i:10;s:39:"syntaxhighlighter/syntaxhighlighter.php";i:11;s:27:"wp-pagenavi/wp-pagenavi.php";}' WHERE `option_id`=35;

10. After reverting the changes made in step 2, refresh the page again, and the site displays normally.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系