Amazon.com Widgets
rssRSS: SubscribeComments


SOLVED! Fix WordPress Error – Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 1 in [root]/wp-includes/classes.php on line 210 211

The Problem

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

The Solution!

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.

Tagged as: , , , , , , , , ,



18 Comments

  1. THANK YOU!

    I have looked for an answer for about 10 days on this. I had the same errors and after trying this – I am back up with permalinks.

  2. But when I switch back to the “nice” permalinks, I run into the same problem ALL over again. :-/

  3. Did you make sure all your plugins were disabled still when switch back to the permalinks structure you wanted? I ran into the problem you mentioned when I did not have the plugins disabled. You should be able to re-enable the plugins AFTER switching back to your desired structure

  4. Yes, all plugins disabled. After switching them back on (no matter if it was one by one or all of them in one fell swoop), everything seems okay until I try editing a page or post. Then the error shows up again … After lots of testing I think it’s maybe caused by the Now Reading plugin. (Though that’s really weird because I use the same WordPress version and plugin version for another blog as well, and I don’t get those errors over there!)

  5. thanks, i have been looking for the answer too. thank god that you decided to document the solution. may god bless you.

  6. Thanks for the post. Saved my behind.

    Rob

  7. Thanks too ! your post save me. I had this problem after installing WP super cache plugin. So, to solve it, I uninstall only this plugin, Go to the Permalinks settings (under the Settings header in the admin dashboard). and switch back to the value default. A refresh on my home page, now it rocks !

  8. OMG! Thank you so much for this post. I had been fighting with my site for 2 hours and your idea fixed it in 5 minutes.

  9. Thank you and 100 times thank you! (and to Google for bringing me to you) you have really saved me a lot of pain

  10. I agree. Thanks so much for posting this. I was really nervous when I got that message and you really saved the day!

  11. THANKS!!!…And I use Joomla!!…All I had to do was remove a number from a permalink that had been set for a blog post through my blogging interface “Easyblog”!

  12. Thank you oh thank you! This really helped me fix the problem.

  13. Thanks so much ! this post saved me :-) I did exactly as you proposed and everything is back to normal. Than you so very much.

  14. Thank You! It worked! I was in full panic mode there for about 10 minutes!

  15. Thank You a lot! I today only updated to 3.3 and it was showing error. Now it is all ok.

  16. You ARE my life saver!

    If I can tell you, The error was 250mb in an error_log.. but now it’s gone because I’ve applied your solution

    thanks in advance dude~!

  17. Thanks! :)))

Leave a Response