Recently I was unfortunate enough to get a random error while editing some articles in WordPress. All I had done was update a few articles and made no major changes to anything. Suddenly, on most pages of the site – and even in the wordpress admin dashboard, I would get the following error repeated a dozen or more times at the top of the page:
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 1 in [yoursite]/wp-includes/classes.php on line 210
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 1 in [yoursite]/wp-includes/classes.php on line 211
At one point, while browsing through different categories, I also received the following error and the page did not even load fully:
Warning: Cannot modify header information – headers already sent by (output started at [yoursite]/wp-includes/classes.php:210) in [yoursite]/wp-includes/pluggable.php on line 890
Luckily, after a few hours of some very unhelpful google research, then plenty of trial and error on my end, I was able to find the solution.
The problem apparently was caused by some sort of corruption with the permalinks structure. Also pointing to this fact is that lines 210 and 211 in classes.php (see the error message) have to do with permalink searching / matching if you read around a bit in that file. So, realizing this, I disabled all of my plugins (I believe the culprit here was probably Dean’s Permalinks Migration, but I disabled them all to be sure), then went into the WordPress Permalinks settings (under the Settings header in the admin dashboard). There I switched back to the first default setting, which is for %post_id% only, saved the settings, verified the site was now working, then switched back to my custom permalinks setting. Keep in mind plugins were disabled while doing this. This did NOT work when I had tried it earlier with plugins still enabled.
The problem was now fixed!
Also possibly of note is that my previous and current permalinks structure was set at /%category%/%postname%/ – which after further research is SEO (search engine optimization) friendly, however it is very hard on your server load and wordpress setup. This may have led partly to the problem, or it may not have. A better setup would be /%year%/%monthnum%/%category%/%postname%/ since having a numerical start to your permalinks structure fixes this problem. I will probably switch over to this in the near future.