• Resolved Malae

    (@malae)


    I have several WordPress sites running on a LAMP server with PHP 7.2, 7.3 and 7.4 installed. All sites with various themes were running on PHP 7.4. When PHP 8.0.1 was released early in January, it was added. WordPress version was 5.6. I checked all the sites and was happy that all except one could be opened, although some had errors from plugins. The site that would not open had a fatal error, not seen since moving from PHP 5.6 to 7.x, where mysql was deprecated.

    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /wp-includes/wp-db.php:1685
    Stack trace:
    #0 /wp-includes/wp-db.php(632): wpdb->db_connect()
    #1 /wp-includes/load.php(527): wpdb->__construct('root', 'rootpw', 'wp_fwhr', 'localhost')
    #2 /wp-settings.php(124): require_wp_db() 
    #3 /wp-config.php(100): require_once('/srv/http/wordp...') 
    #4 /wp-load.php(37): require_once('/srv/http/wordp...') 
    #5 /wp-blog-header.php(13): require_once('/srv/http/wordp...') 
    #6 /index.php(17): require('/srv/http/wordp...') 
    #7 {main} thrown in /wp-includes/wp-db.php on line 1685

    Although no other site displayed this error and it had not occurred with any PHP 7.x version, it was suspected that the error was perhaps caused by the Twenty Sixteen theme, or a plugin. However, changing to Twenty Twenty-One theme and deactivating all the plugins does not help, but reverting back to PHP 7.4 stopped the error.

    There is no line: define('WP_USE_EXT_MYSQL', true); in the wp-config.php file.
    The .htacess file contents were replaced with the basic vanilla version.
    The index.php is unchanged.
    Updating WordPress to 5.6.1 has made no difference.
    Thorough checks for errors in the php.ini file showed nothing missing: mysqli, mysqlnd and pdo_mysql extensions installed and showing as loaded in the terminal with php -m.

    What am I missing? Does anyone familiar with all the core files see something in the stack trace?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Dion

    (@diondesigns)

    The PHP handler in your webserver may be different than the CLI version of PHP. Go to Site Health, click the Info tab, display the Server dropdown, and check the value of PHP SAPI. If it contains any combination of cgi, fcgi, or fpm, then you’ll need to run a different command (php-fpm -m if the value contains fpm, php-cgi -m otherwise) from the command line to see the list of loaded modules/extensions.

    Thread Starter Malae

    (@malae)

    Hi Dion,

    Thank you for your suggestions. The server PHP SAPI is apache2handler and I presume php -m is ok.

    I have a lot to learn about how the modules are loaded. When following WordPress recommendations about modules, if I add modules like ‘dom’, mysqlnd and mcrypt to the the the php.ini file, I receive a message for each, as in:
    PHP Warning: PHP Startup: Unable to load dynamic library 'dom' (tried: /usr/lib/php/modules/dom (/usr/lib/php/modules/dom: cannot open shared object file: No such file or directory), /usr/lib/php/modules/dom.so (/usr/lib/php/modules/dom.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    However, if I look in PHP Info, I find that dom, mysqlnd and mcryptare enabled presumably by default along with others not listed in the php.ini file. In the case of mysqli, pdo_mysqli the Client API version is mysqlnd 8.0.2.

    After playing musical chairs with the settings and having commented out modules that are not loading according to php -m, I found that the mysql_connect has gone, but I have no idea what the actual cause was.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP 8.0 Fatal error’ is closed to new replies.