Site not working, trouble finding source

I'm currently working on a site (current test version at morten.madsi.co) and I have a recurring bug that I have tried to fix several times, but it has come back each time.

Whenever I try to access the site or wp-admin, I get this error message:

Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in /srv/users/serverpilot/apps/mortenhake/public/wp-content/themes/twentyfifteen/functions.php:60 Stack trace: #0 /srv/users/serverpilot/apps/mortenhake/public/wp-settings.php(387): include() #1 /srv/users/serverpilot/apps/mortenhake/public/wp-config.php(49): require_once('/srv/users/serv...') #2 /srv/users/serverpilot/apps/mortenhake/public/wp-load.php(39): require_once('/srv/users/serv...') #3 /srv/users/serverpilot/apps/mortenhake/public/wp-admin/admin.php(31): require_once('/srv/users/serv...') #4 /srv/users/serverpilot/apps/mortenhake/public/wp-admin/themes.php(10): require_once('/srv/users/serv...') #5 {main} thrown in /srv/users/serverpilot/apps/mortenhake/public/wp-content/themes/twentyfifteen/functions.php on line 60

Since it mentions the theme, I thought that was the problem, but when I use another theme, I get the same error message just with that theme instead.

I have used a few methods to try to isolate the problem. If I deactivate all plugins, using ftp, there is no change.
When I disable the current theme using ftp, I can access wp-admin again. So earlier I thought the theme I was using, Peliegro, was to blame. However, when I activate another theme instead, I get the same error message. Earlier, I managed to restore the site completely simply by restoring the themes by using a recent backup. (Snapshot, themes only). I have not done that this time as it was apparently just a temporary fix and I would like to isolate the error. I have not updated or changed any of the themes since that backup.

What I'm hoping for is help with is understanding the error message.

I have also left the site without an active theme so wp-admin is accessible, and support access, if that can be of use.

  • Dimitris
    • Support Star

    Hey there Madsi Nordbustad,

    hope you're doing good and thanks for reaching us! :slight_smile:

    It seems that this error is due to the deprecated mysql_* functions in PHP v.7.
    http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php

    A workaround could be one posted here
    http://stackoverflow.com/questions/8225198/phpmyadmin-the-mysql-extension-is-missing/8225474#8225474

    As I noticed that you're using PHP v.7, you may downgrade this to PHP v.5.6 and see if you still confront issues with your setup.

    For both these actions, you may have to contact your hosting provider as you may understand.
    They can also double check that php-mysql are up and running in your server instance.

    The sure thing is that WPMUDEV products and default WP themes are PHP7 compatible and shouldn't cause any issues like that.

    I look forward for your feedback,
    Dimitris :slight_smile:

  • Madsi Nordbustad
    • Flash Drive

    Downgrading to PHP 5.6 did the trick. I'm going to make sure of compatibility before I try upgrading to 7. again.

    On that note, I installed PHP Compatibility Checker from the repo to see if I could find out which theme/plugin caused the problem. I noticed it return errors and warnings for both standard WP themes and some of your plugins, including deprecated mysql_-functions.

    Do you know of any other, reliable, way of discovering PHP7-incompatabilities?

  • Adam Czajczyk
    • Support Gorilla

    Hello Madsi!

    I'm glad that you managed to get your site up and running again.

    As for warnings and errors. We're constantly updating our plugins to make sure they are fully compatible though there are still places that may be triggering warnings. There shouldn't be "fatal errors" because of PHP 7 though.

    WordPress core also shouldn't return fatal errors on PHP 7. In fact there are many member of our community that already switched to PHP 7.x some time ago and does not experience such issues. Myself, I'm using PHP 7.x for some of my test sites with no issues as well.

    This leads me to the point that most likely the main issue here is a bit different :slight_smile: Default WP themes and WP core are compatible with PHP 7. The "stack trace" results can sometimes be a bit misleading as for example the line 60 of "functions.php" file of "Twenty Fifteen" theme is actually la comment line and the nearest line is the

    load_theme_textdomain( 'twentyfifteen' );

    line which is a core WP function, therefore should be compatible with PHP 7. That is, unless the theme has been modified and there's some other code in that place (that may indeed refer to the "mysql_" extension that's been removed).

    The most likely reason here would be either that some plugin(s) are not compatible or the initial WP "core" install was very outdated, though I'd bet on the first one. I can't say for 3rd party plugins but as for ours - I'm aware that some of them still may produce issues so it would be best if you could tell me which ones did you manage to indicate as causing warnings/errors so I could check them and report to developers if necessary.

    I would also recommend checking PHP error reporting settings if you do have access to PHP configuration. This is extremely rare but in case of very strict settings some minor notices and warnings can be causing script termination (E_ALL, E_STRICT) with WP debugging turned on :slight_smile:

    Best regards,
    Adam

  • Madsi Nordbustad
    • Flash Drive

    Thanks for clearing that up, very helpful. Now I'm left with only a couple of candidates to test, which will come later. At least I finally have a stable WP install to do that from.

    In this case the initial WP core was from 2008, I guess that qualifies as old. But that's on the live site, which I'm not switching to 7.0 to test. And on this test version I started with a fresh WP install and imported themes, plugins, uploads and database.

    Those of your plugins returning errors are the Dashboard, E-Newsletter and the Upfront theme. I don't really expect any of those to be te problem but I'm glad I brought it up as I learned something from it.

  • Adam Czajczyk
    • Support Gorilla

    Hello Modsi Nordbustad!

    Thanks for your response, this is very helpful!

    Would you mind if I asked you just one more question about these three plugins of ours? I'd like to know if they were causing "Fatal Errors" for you or "warnings" or "notices". It would be great if you could share content of these related messages with me so I could compare them with what I can find on my own setup.

    Thanks!
    Adam

  • Madsi Nordbustad
    • Flash Drive

    This is what I've got. No fatal errors.

    FILE: /srv/users/serverpilot/apps/mortenhake/public/wp-content/plugins/wpmudev-updates/template/support-system.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    77 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0 - use mysqli instead.
    313 | WARNING | Function name "__render_list" is discouraged; PHP has reserved all method names with a double underscore prefix for future use
    334 | WARNING | Function name "__error_reporting" is discouraged; PHP has reserved all method names with a double underscore prefix for future use
    376 | WARNING | Function name "__value_format" is discouraged; PHP has reserved all method names with a double underscore prefix for future use
    390 | WARNING | Function name "__const_format" is discouraged; PHP has reserved all method names with a double underscore prefix for future use
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/plugins/e-newsletter/email-newsletter-files/phpmailer/class.phpmailer.php
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
    ----------------------------------------------------------------------------------------------------------------------------
    526 | WARNING | INI directive 'safe_mode' is deprecated since PHP 5.3 and removed since PHP 5.4.
    939 | WARNING | INI directive 'safe_mode' is deprecated since PHP 5.3 and removed since PHP 5.4.
    1867 | ERROR | Function set_magic_quotes_runtime() is deprecated since PHP 5.3 and removed since PHP 7.0
    1869 | ERROR | INI directive 'magic_quotes_runtime' is deprecated since PHP 5.3 and removed since PHP 5.4.
    1876 | ERROR | Function set_magic_quotes_runtime() is deprecated since PHP 5.3 and removed since PHP 7.0
    1878 | ERROR | INI directive 'magic_quotes_runtime' is deprecated since PHP 5.3 and removed since PHP 5.4.
    ----------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/plugins/e-newsletter/e-newsletter.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------
    2254 | ERROR | Using 'break' outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0
    --------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/themes/upfront/library/models/class_upfront_entity_resolver.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    143 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    -------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/themes/upfront/elements/upfront-posts/loader.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    174 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    -------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/themes/upfront/elements/upfront-posts/lib/class_upfront_posts_posts_view.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------
    65 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    92 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    -------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/themes/upfront/elements/upfront-comment/lib/upfront_comment.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ------------------------------------------------------------------------------------------------------------------------
    75 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    78 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    93 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    94 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    ------------------------------------------------------------------------------------------------------------------------

    FILE: /home/madsi/public_html/wordpress/wp-content/themes/upfront/elements/upfront-post-data/lib/parts/class_upfront_post_data_partview_comments.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    336 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    339 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    354 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    355 | ERROR | 'clone' is a reserved keyword introduced in PHP version 5.0 and cannot be invoked as a function (T_CLONE)
    ----------------------------------------------------------------------------------------------------------------------------------------------------

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.