• Resolved Francesco

    (@fcolombo)


    Hi,

    I have a WordPress installation (4.9.8) with W3 Total Cache (0.9.7) on a LiteSpeed/Apache shared server and PHP 5.6. All is working fine.

    In W3TC I have enabled: Page Cache (Disk: Enhanced), Minify (Disk), Database Cache (Disk), and Browser Cache.

    If I upgrade to PHP 7.2 (or 7.1 or 7.0), the website returns a 503 error (only for not logged-in users – the admin area is still accessible).

    In my logs, I have this:

    
    PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/~/public_html/wp-includes/wp-db.php:1564
    Stack trace:
    #0 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(145): wpdb->db_connect(true)
    #1 /home/~/public_html/wp-includes/wp-db.php(592): W3TC\DbCache_Wpdb->db_connect()
    #2 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(252): wpdb->__construct('redacted', 'redacted', 'redacted', 'redacted')
    #3 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_WpdbInjection.php(38): W3TC\DbCache_Wpdb->default_initialize()
    #4 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(152): W3TC\DbCache_WpdbInjection->initialize()
    #5 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(379): W3TC\DbCache_Wpdb->initialize()
    #6 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_WpdbInjection_QueryCaching.php(229): W3TC\_CallUnderlying->initialize()
     in /home/~/public_html/wp-includes/wp-db.php on line 1564
    

    Which makes me think that W3TC’s Database Cache is struggling when on PHP 7.

    Reverting back to PHP 5.6 fixes the problem.

    Am I missing anything obvious, and does anyone know if there’s any quick win to get around this?

    Thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)
  • bgdstr

    (@bogdanstratulat)

    is the plugin updated to the latest version? Please make sure to update to 0.9.7 .

    Thread Starter Francesco

    (@fcolombo)

    Hi, thank you for your reply. Yes, the plugin is updated to the latest version.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    If you disable DB caching does the issue persists?

    Thread Starter Francesco

    (@fcolombo)

    Hi @vmarko and @bogdanstratulat

    I can confirm that disabling DB caching and upgrading to PHP 7.2 works just fine.

    It’s when I re-enable DB caching that the 503 errors start.

    Thanks for your help.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,
    If you are using Database Cache method: Disk, Try using other, memory based caching solution like memcached

    Thread Starter Francesco

    (@fcolombo)

    The website is on a shared server, so only Disk caching is available unfortunately.

    Do you have any other suggestions?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    You need to check if your MySQL extension is enabled

    You can set
    define(‘WP_USE_EXT_MYSQL’, true);
    in your wp-config.php to make WordPress use the mysqli extension.

    Thread Starter Francesco

    (@fcolombo)

    Thanks for the suggestion, @vmarko.

    Would define(‘WP_USE_EXT_MYSQL’, true); force WP to use MySQL by default, rather than MySQLi?

    “Use MySQLi when available by default” was introduced in 4.9.2 and I feel that forcing to use MySQL is like backtracking – Are there any plans for the DB cache to work using MySQLi too?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    Yes, you should use it when available. You should ask your hosting company to check the PHP and MySQL config settings
    Using define(‘WP_USE_EXT_MYSQL’, true); is a workaround if MSQLi is not available.

    Thread Starter Francesco

    (@fcolombo)

    Thank you.

    On my server, the mysqli extension was enabled.

    I ticked it off and selected nd_mysqli instead, and the problem is solved.

    Thanks again for all your help!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @fcolombo,

    Glad to know that the issue is resolved.

    Please take some time and post a 5-star review here if convenient. This shouldn’t take more than a couple of minutes. Our goal is to continue offering a top-notch product, and your review could greatly help us to continue doing so.
    Best regards

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Database Cache causing 503 errors when upgrading to PHP 7’ is closed to new replies.