Aug 15

How to resolve: Fatal error: Call to undefined function nocache_headers() in /wp-admin/admin.php on line 32

How to resolve: Fatal error: Call to undefined function nocache_headers() in /wp-admin/admin.php on line 32

It seems this happens more often than one would expect. After it happened to me I was reading through a bunch of blogs and several people after an upgrade and my other scenarios en up encountering this issue. The first reason that pops up while doing a search or if you start thinking about it is that a file is missing or in this case it has been zeroed out. Apparently the main culprit is then that certain WordPress files are wiped clean. Even though the file is still present it shows a size of 0 bytes sometimes 2 bytes. If you open it then you´ll see it is completely empty. Another thing you could do is simply follow some debugging steps. First you can see if your admin.php which is being referenced is there, then you´ll see that the nocache_headers function is being called. This function can be located in wp-includes/functions.php. However in my case what was causing this issue was a plugin that under certain circumstances would clear out my wp-config.php file. Thus I would recommend securing your htaccess (or web.config in the case of a Windows host) and your wp-config.php so they cannot be edited by an application on your web server (theme, plugin, etc in the case of WordPress).

Solution 1: Restore a file system Backup

If you have a recent backup and have made no chances to the files after that you might simply restore that. It would place the files that were working before with not too much hassle.

Solution 2: Restore missing or zeroed out files from a WordPress installation zip file

Get the installation files for your version of WordPress and extract them. Then via whatever file explorer you have on your web server sort your files by size and start matching them. Whatever file is missing or has a different size simply copy it over to your webserver. You could simply copy over all the files if you haven’t made any modifications but you will need to make sure you don’t wipe your wp-config.php or other files that already have modifications. As always, do backup your installation before making any changes.

wp-config.php: Sometimes it is the only thing you are missing

Obviously you need a backup of this file or again capture all the configuration information you had there. I was going like crazy through all the files and debugging. I tried Solution 2 and I was still having issues, and then I thought perhaps a central file that is always called and loads references is missing and the only one I had not overwritten yet was wp-config.php. So there you have it, sometimes it is as easy as the file you have in front of you staring you in the face.

Enhanced by Zemanta

5 comments

Skip to comment form

  1. Thank you – it was wp-config!

  2. Fatal error: Call to undefined function nocache_headers() in /home/latestwish/public_html/wp-admin/admin.php on line 33

    • moizuddin on February 23, 2017 at 12:24 pm
    • Reply

    Thanx a lot bro. Solution 1 solved my problem… helps me a lot.

    • visumverum.eu on March 17, 2017 at 9:54 am
    • Reply

    can be opcache you could flush from php

  3. THANK YOU IT WAS WP CONFIG
    EMPTY FILE
    BUT STILL HAVE PROBLEM
    I CHANGE TO 777
    STILL HAVE PROBLEM TO EDIT

    THANK YOU ANYWAY

Leave a Reply

%d bloggers like this: