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

You may also like...

7 Responses

  1. Rob Healey says:

    Thank you – it was wp-config!

  2. aditya says:

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

  3. moizuddin says:

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

  4. says:

    can be opcache you could flush from php

    I CHANGE TO 777


  6. rodmx says:

    Thank you! Solution 2 worked perfectly good! Do you know the reason why this happened and how to avoid it in the future? Thanks a lot!

  7. Avijit says:

    Yes 3rd option helped me too. I removed the WC key Values from config file then started working.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.