Support » Localhost Installs » Problem copying site from server to local: undefined function nocache_headers()

  • Resolved scienceofspock

    (@scienceofspock)


    I have been tasked with “recovering” a website that my company created a while ago. When I say recover, what I mean is that we have no version control repo for this site and it hasn’t been updated in a while, so I need to copy it down to my localhost, standardize the folder structure to match our other stuff, update the site/plugins, put all that into a git repo, and then redeploy to the site. I have done this numerous times before, the process is pretty straight forward, Set up a virtualhost, export the database as a sql file, create a local database and user, import the sql file into the new database, adjust the wp-config file to match the database settings and copy the site files to my local using winscp.

    This one particular site has something wrong with it and when I try to access wp-admin locally, it throws the following fatal error:

    Fatal error: Uncaught Error: Call to undefined function nocache_headers() in wp-admin\admin.php on line 33

    For reference, I am on Windows 10, running Wamp64 and the server is Ubuntu 18.04 LTS with standard LAMP stack. The wordpress install is on version 4.9.8. I know that error message is technically wrong, as the function is defined in wp-includes/functions.php, but *something* is going on that is preventing me from running this site on my Windows machine, while it runs perfectly fine on the server (Admin included). I thought it might be a weird OS/php version issue, but I have tried php 7.0.33, 7.1.29, 7.2.18 and even 5.6.40 just in case and the result is the same each time.

    I have disabled the plugins by renaming the plugin directory and setting the active_plugins row in the options table to ‘a:0:{}’ but the problem persists. I have seen a few examples of this online, but they’re mostly caused by wp- files in the root getting zeroed out, or a bad plugin, and that’s not the case here. What other steps could I try to get this working locally?

    Thanks in advance for any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter scienceofspock

    (@scienceofspock)

    Update: I have attempted changing the theme in the database, and even that doesn’t fix the issue.

    Thread Starter scienceofspock

    (@scienceofspock)

    I figured this out and it was a stupid, stupid issue. I have a custom wp-config.php setup that breaks out the individual sections into different files and then includes them from wp-config.php proper. My pathing was incomplete, so at the root of the site, it was actually loading all the parts of my wp-config, but from wp-admin, it couldn’t find the wp-config files because it was essentially looking in ‘./’ instead of going back to the document root, and because I tried to make sure the files exist BEFORE including them, it did not even try to include them because it couldn’t find them. So much for trying to overthink and prevent stupid error messages.

    Moderator Steve Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    Glad that you solved this.

    >> I have a custom wp-config.php setup that breaks out the individual sections into different files and then includes them from wp-config.php proper. <<

    Why?

    Thread Starter scienceofspock

    (@scienceofspock)

    It stems from the way some of our sites were initially set up. Some repos are actually used for multiple sites (but not using wp multisite, since that wasn’t around when these were built), with the only difference being the theme folder and database. Our setup allows us to work on those multisites locally by copying the wp-config.php to a new file that is basically <domain name>.wp-config.php and then inside wp-config.php we have code that loads the proper <domain name>.wp-config.php based on the domain of the site. so if I browse to a local wp site at the URL local.foo.com, wp-config.php will load local.foo.com.wp-config.php. If I browse to a different local wp site at local.bar.com, it will load local.bar.com.wp-config.php. Both those sites are the same physical directory and same repo. It’s kind of a weird setup, but it works for us.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problem copying site from server to local: undefined function nocache_headers()’ is closed to new replies.