WordPress Categories Disappear…

Right, a few days ago I mentioned I’d be posting something about an interesting WordPress problem.

I notice within various forum posts and such like on the Internet that some WordPress administrators have experienced a situation whereby their blog’s categories and tags disappear.

Undoubtedly the first thing one tends to think when seeing this is that the database has become partially unavailable, corrupt or data has been deleted.

However before you go reaching for that backup, assuming you have one, make sure you check the available disk space of your server’s volumes (drives). In fact I wouldn’t do anything else until you’ve checked that, in order to avoid any risk of data-damage.

As noted in various forum posts and responses over the Internet, the problem can occur with MySQL when all available disk space has dried up.

Typical culprits for eating up space on web servers are log files.  It’s good practice to cycle, archive and shift these on a regular basis.  There might be one though you are missing..

php_errors.log is a special file that logs details of PHP warnings and errors when your code is run.

You can alter which warnings and errors are logged, and indeed where they are logged, by locating your php.ini file and looking for the error_log entry.

A combination of logging everything and, say, an undefined variable in a script that is in steady demand will cause php_errors.log to fill up at an alarming rate.

Typically on a ‘production server’ hosting a public web site it will be a security risk to openly reveal details of internal or server-side warnings and errors to the end-user.  As a result PHP will likely be configured not to show them and thus a new variable being used without being defined, whether it’s a simple typo or a bit of lazy coding, will result in a ‘silent’ warning notice being generated.

More often than not such a coding mistake will have no effect on the ability of the PHP script to perform its job and therefore will not visually impact the web page from the user’s point of view.  It’s quite easy for it to go unnoticed until you check the log.

If you’ve found you do have a rapidly growing php_errors.log there are, of course, two ways to impede its spread.  The quickest may be to head to php.ini and look for the error_log entry where you can switch it off…

That isn’t really an ideal solution even if it does solve the problem.  There are plenty of wheels in the world already so, rather than inventing another and repeating instructions others have already written, I’m going to point you towards Google, or your prefered search engine, with a search for ‘turn php_errors.log off’ or something similar if that is what you choose to do.

The better solution is to correct the code if you can.  The error log does prove quite useful here as it will help you find out which file and what part of the PHP code is the source of the warnings.

Unfortunately, if the log file has grown so big you are short on space, you may find the file is too large to open.  Consider opening just the last few lines of the file, if your system allows, as the most prevalent warnings are likely to be there.  Alternatively you might just delete it and wait for it to come back with new warnings and errors (could be hours or days… test out your site fully so you’re sure to run the code causing the warning and then check the log file).  You’ll then be able to open a smaller file.  (Don’t delete a log file unless you are sure it won’t be of use.)

Many WordPress sites have plugins.  It’s possible one or more of these might be triggering warning notices.  From the entries in the error log file you should be able to determine the plugin, or plugins, tripping those warnings.  You can then disable and remove them or check with the author for a fix.

Getting back to the mysterious case of the disappearing tags and categories.  If it is caused by a lack of disk space, provided nothing else has gone wrong, you should find they happily return once you’ve created a little more room.

Related Products

This entry was posted in Web Design and tagged , , , , , , , . Bookmark the permalink.

Comments are closed.