• Resolved kazerniel

    (@kazerniel)


    Yesterday I switched my site from PHP 7.4 to 8.1 in cPanel’s MultiPHP Manager. It immediately started giving 500 Internal Server Error, and the message below in the debug log:

    [31-Jan-2023 10:43:39 Europe/Budapest] PHP Fatal error:  Uncaught Error: Call to undefined function trailingslashit() in /home/aszex477/public_html/wp-includes/class-wp-textdomain-registry.php:103
    Stack trace:
    #0 /home/aszex477/public_html/wp-includes/l10n.php(784): WP_Textdomain_Registry->set('default', 'hu_HU', '/home/aszex477/...')
    #1 /home/aszex477/public_html/wp-includes/load.php(1401): load_textdomain('default', '/home/aszex477/...', 'hu_HU')
    #2 /home/aszex477/public_html/wp-includes/load.php(162): wp_load_translations_early()
    #3 /home/aszex477/public_html/wp-settings.php(37): wp_check_php_mysql_versions()
    #4 /home/aszex477/public_html/wp-config.php(88): require_once('/home/aszex477/...')
    #5 /home/aszex477/public_html/wp-load.php(50): require_once('/home/aszex477/...')
    #6 /home/aszex477/public_html/wp-blog-header.php(13): require_once('/home/aszex477/...')
    #7 /home/aszex477/public_html/index.php(17): require('/home/aszex477/...')
    #8 {main}
      thrown in /home/aszex477/public_html/wp-includes/class-wp-textdomain-registry.php on line 103 

    I tried switching the site back to PHP 7.4, but it still throws the same error.

    I don’t really know PHP, but after some googling I came across this Stack Overflow thread where I tried the linked answer. That removed the white screen and made the site display an error message that it needs MySQL installed (even though it already is). That didn’t seem like an improvement, so I switched that line in class-wp-textdomain-registry.php back to what it was.

    Could you help me resolve this error? I don’t mind staying on PHP 7.4, the only reason I tried upgrading was because WordPress kept telling me that it was deprecated ??

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    I think something has damaged your WordPress-Core files and your site could work fine with php8

    Try downloading WordPress again ( make sure the downloaded version is the same as the currently delpoyed version ), access your server via SFTP or FTP, or a file manager in your hosting account’s control panel, and delete then replace your copies of everything except the wp-config.php file and the /wp-content/ directory with fresh copies from the download. This will effectively replace all of your core files without damaging your content and settings.

    Some uploaders tend to be unreliable when overwriting files, so don’t forget to delete the original files before replacing them.

    Thread Starter kazerniel

    (@kazerniel)

    Thanks for the response! I followed the steps, and now the site displays that MySQL error message again:

    Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

    I created a /phpinfo.php file if you want to check out what that says. I found a few guides online about the error message but it’s wayyy above my head.

    Configuration File (php.ini) Path: /opt/alt/php81/etc
    Loaded Configuration File: /opt/alt/php81/etc/php.ini
    Scan this dir for additional .ini files: /opt/alt/php81/link/conf
    Additional .ini files parsed: /opt/alt/php81/link/conf/default.ini

    Neither the etc nor the conf directory seems to exist or be accessible by FTP.

    Hi, oh sorry I didn’t see that error message.

    In this case you need to contact your hosting provider, if you manage the hosting server yourself then you can install php-mysql like this:

    apt install php81-mysql

    or

    apt install php-mysql
    Thread Starter kazerniel

    (@kazerniel)

    I think MySQL is already installed, as the WordPress site was running fine before I tried switching it to PHP 8.1. cPanel also shows that WordPress has a MySQL table.

    You don’t have to install mysql but the mysql php extension php-mysql

    Every php version needs its own version of this extension thus php81-mysql

    I am not sure about that but maybe you also need to restart apache like this:

    systemctl restart apache2
    Thread Starter kazerniel

    (@kazerniel)

    Thanks, but I can’t find an option for any of these in cPanel, so I’ll try to contact the host to restore a previous backup of the site.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Switching to PHP 8.1 gives fatal error’ is closed to new replies.