Search code examples
mysqlwordpress

Call to undefined function wp_get_wp_version()


Background: Several years ago I developed a simple WordPress site for my local government that they took over in terms of managing/updating. This summer a local resident contacted me stating the site wasn't loading, and I reached out to the current admin user to see if I could assist. When attempting to access the site's login (or any other resource), we see the message "There has been a critical error on this website. Please check your site admin email inbox for instructions."

The current admin has assured me they've searched their mailbox and have no emails from WordPress with a link to recovery mode logins. I've since changed the admin user's email to mine via MySQL, but haven't received any emails from WP regarding the site. The host, Network Solutions, told me they cannot restore a backup as they're only retained for 30 days, and I was brought in about 5 months after the site went down in February.

So far, I've tried the basics like:

  • Renaming the plugins folder and active theme folder via SFTP, without any impact.
  • The WP version appears to have been upgraded around the time this issue occurred. Either from 6.3.1 to 6.6.2, or unsuccessfully from 6.6.2 to 6.7.1. The current WP version is reported 6.6.3. I do not know the PHP version and the host is unable to provide that info. I will try to upload a PHP file to determine it later this evening.
  • I can access the MySQL database where I also disabled all plugins, but still no joy
  • I also manually replaced WP 6.6.3 with the original 6.3.1, but this still did nothing.

I updated the wp_config.php file to enable debugging, and see the following message in the output, though I'm unsure how to resolve it. Has anyone ever seen this?

Uncaught Error: Call to undefined function wp_get_wp_version() in /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-includes/blocks/index.php:30 Stack trace: #0 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-includes/class-wp-hook.php(324): register_core_block_style_handles() #1 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #2 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-settings.php(700): do_action() #4 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-config.php(81): require_once('/data/user/2018...') #5 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-load.php(50): require_once('/data/user/2018...') #6 /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-blog-header.ph in /data/user/2018/295/5738/wordpress/.5f11b27f131494a1c014fcced2f13165/wp-includes/blocks/index.php on line 30

UPDATE

@Dmitry Leiko's suggestion to rollback to 6.2.6 worked in part to get the site's pages loading, partially. I downloaded the WP 6.2.6 zip and uploaded it via FTP, excluding the content directory. Once that was done I was getting the below message trying to login:

Forbidden You don't have permission to access /wp-admin/upgrade.php on this server.

Renaming hte site's .htaccess file to .htaccess_old got back to the login page, but I was being prompted to update the MySQL database since the version value in the version.php file was wrong. So I did have to login to MySQL and execute SELECT option_value FROM dbname.wp_options WHERE option_name = 'db_version' to determine the correct MySQL value, which I added to the wp-includes/version.php file, and now I'm back in.

Thank you to everyone who tried to help, I very much appreciate it!


Solution

  • You can try to create custom function in your yourTheme/function.php:

    if (!function_exists('wp_get_wp_version')) {
        function wp_get_wp_version() {
            static $wp_version;
    
            if (!isset($wp_version)){
                require ABSPATH . WPINC . '/version.php';
            }
    
            return $wp_version;
        }
    }
    

    enter image description here

    Also you can try rollback your wordpress to 6.2.6

    enter image description here