Daniel's Blog

Repairing wordpress in critical error

Today the client got an error in their wordpress site that they had setup. I've used wordpress off and on for over a decade no so when they asked me to take a look I went for it.

Going to the site gave the error:

There has been a critical error on this website. Please check your admin email inbox for instructions. 

of course there is no admin email so what to do.

I have ssh access so I ssh into the machine

$ ssh wordpress-vm 

Checking the process list shows Apache2 and mysqld are running

$ ps aux

...
www-data  1679  0.1  2.8 579068 106744 ?       S    05:56   0:01 /usr/sbin/apache2 -k start
www-data  1929  0.2  3.1 585416 119780 ?       S    06:13   0:01 /usr/sbin/apache2 -k start
www-data  1932  0.1  2.5 500312 98468 ?        S    06:13   0:00 /usr/sbin/apache2 -k start
www-data  1933  0.2  2.8 579148 109120 ?       S    06:13   0:00 /usr/sbin/apache2 -k start
www-data  1936  0.1  2.6 576244 101632 ?       S    06:13   0:00 /usr/sbin/apache2 -k start
root      1956  0.0  0.1  92728  6420 ?        Ss   06:15   0:00 sshd: xxxxx[priv]
daniel    1962  0.0  0.0  92864  3756 ?        S    06:15   0:00 sshd: xxxxx@pts/0
daniel    1963  0.0  0.1  21020  4536 pts/0    Ss   06:15   0:00 -bash
daniel    2000  0.0  0.0  38300  3076 pts/0    R+   06:20   0:00 ps aux
mysql     2456  0.4  9.9 1167804 376892 ?      Sl   Mar27 361:02 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root     18891  0.0  0.0      0     0 ?        S    Apr13   0:12 [kworker/u2:0]
root     23986  0.0  0.7 482136 28272 ?        Ss   May18   0:01 /usr/sbin/apache2 -k start
root     28486  0.0  0.0      0     0 ?        S    Apr27   0:09 [kworker/u2:2]
www-data 31957  0.0  3.0 579244 114092 ?       S    03:53   0:08 /usr/sbin/apache2 -k start
www-data 31961  0.0  3.0 581420 116752 ?       S    03:53   0:08 /usr/sbin/apache2 -k start

First check the status of apache:

$ sudo /etc/init.d/apache2 status
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2023-09-29 21:50:33 UTC; 7 months 18 days ago
  Process: 2452 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
  Process: 638 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 752 (apache2)
    Tasks: 11 (limit: 4915)
   CGroup: /system.slice/apache2.service
           ├─  752 /usr/sbin/apache2 -k start
           ├─23482 /usr/sbin/apache2 -k start
           ├─23805 /usr/sbin/apache2 -k start
           ├─23811 /usr/sbin/apache2 -k start
           ├─23871 /usr/sbin/apache2 -k start
           ├─23872 /usr/sbin/apache2 -k start
           ├─23875 /usr/sbin/apache2 -k start
           ├─23876 /usr/sbin/apache2 -k start
           ├─23877 /usr/sbin/apache2 -k start
           ├─23879 /usr/sbin/apache2 -k start
           └─23881 /usr/sbin/apache2 -k start

It's been good for 7 months

Next check mysqld

$ sudo /etc/init.d/mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2024-03-27 22:27:39 UTC; 1 months 21 days ago
  Process: 2451 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 2416 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 2456 (mysqld)
    Tasks: 36 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─2456 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

It's been good for 1 month and 21 days

Next check error logs in apache:

$ tail /var/log/apache2/access.log
...
wordpress-vm.c.amigocloudplatform.internal:80 xx.xxx.xxx.xxx- - [18/May/2024:21:21:52 +0000] "HEAD / HTTP/1.1" 200 521 "https://www.amigocollect.com/" "Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)"
wordpress-vm.c.amigocloudplatform.internal:80 xxx.xxx.xxx.xxxx- - [18/May/2024:21:22:11 +0000] "GET / HTTP/1.1" 500 2918 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"

Yup, 500 errors

check the error log and found lots of these errors:

$ tail /var/log/apache2/error.log

[Sat May 18 21:22:12.494295 2024] [php7:error] [pid 23998] [client xx.xxx.xxx.xxx:xxxxx] PHP Fatal error:  Uncaught Error: Undefined class constant 'MODS_TPOGRAPHY_FONT_PAIRS' in /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php:993\nStack trace:\n#0 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php(89): TIOB\\Admin->get_font_parings()\n#1 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(182): TIOB\\Admin->init()\n#2 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(113): TIOB\\Main->setup_admin()\n#3 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(86): TIOB\\Main->init()\n#4 /var/www/html/wp-content/themes/neve/inc/core/admin.php(553): TIOB\\Main::instance()\n#5 /var/www/html/wp-includes/class-wp-hook.php(324): Neve\\Core\\Admin->load_site_import()\n#6 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#7 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()\n#8 /var/www/html/wp-settings.php(695): do_action()\n#9 /var/www/html/wp-config.ph in /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php on line 993

Make the error readable:

[Sat May 18 21:37:05.630412 2024] [php7:error] [pid 24188] [client xx.xxx.xx.xx:xxxxxx] PHP Fatal error:  Uncaught Error: Undefined class constant 'MODS_TPOGRAPHY_FONT_PAIRS' in /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php:993
Stack trace:
#0 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php(89): TIOB\\Admin->get_font_parings()
#1 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(182): TIOB\\Admin->init()
#2 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(113): TIOB\\Main->setup_admin()
#3 /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Main.php(86): TIOB\\Main->init()
#4 /var/www/html/wp-content/themes/neve/inc/core/admin.php(553): TIOB\\Main::instance()
#5 /var/www/html/wp-includes/class-wp-hook.php(324): Neve\\Core\\Admin->load_site_import()
#6 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#7 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#8 /var/www/html/wp-settings.php(695): do_action()
#9 /var/www/html/wp-config.ph in /var/www/html/wp-content/plugins/templates-patterns-collection/includes/Admin.php on line 993, referer: https://-------.----/

So something in Neve is loading a plugin called templates-patterns-collection which is having issues.

Find where wordpress is installed:

$ cat /etc/apache2/sites-enabled/000-default.conf | grep DocumentRoot

        DocumentRoot /var/www/html

Use the wordpress cli to disable the plugin.

$ cd /var/www/html
$ $ wp plugin list
+-------------------------------+----------+-----------+----------+
| name                          | status   | update    | version  |
+-------------------------------+----------+-----------+----------+
| akismet                       | inactive | available | 5.1      |
| elementor                     | active   | none      | 3.21.5   |
| elementor-pro                 | active   | none      | 3.1.0    |
| fastly                        | active   | none      | 1.2.26   |
| ga-google-analytics           | inactive | none      | 20240308 |
| iubenda-cookie-law-solution   | active   | none      | 3.10.4   |
| neve-pro-addon                | active   | none      | 2.8.6    |
| themeisle-companion           | active   | none      | 2.10.36  |
| svg-support                   | active   | none      | 2.5.5    |
| templates-patterns-collection | active   | none      | 1.2.9    |
| updraftplus                   | active   | none      | 1.24.3   |
| insert-headers-and-footers    | active   | available | 2.0.11   |
| wpforms-lite                  | active   | none      | 1.8.8.3  |
| wp-mail-smtp                  | active   | none      | 4.0.1    |
| wpml-media-translation        | active   | none      | 2.7.2    |
| sitepress-multilingual-cms    | active   | none      | 4.6.3    |
| wpml-string-translation       | inactive | none      | 3.2.5    |
| elementor-safe-mode           | must-use | none      | 1.0.0    |
+-------------------------------+----------+-----------+----------+

There's the plugin. Time to disable it.

$ wp plugin deactivate templates-patterns-collection 
Plugin 'templates-patterns-collection ' deactivated.

And the site came back online. I updated the neve template then the plugin and everything was good again.