1

Many of us have experienced permalinks suddenly 404'ing for custom post types from time to time. (i.e. on the face of it, nothing has changed in our WP setup - no new plugins installed etc.)

For example, I just had permalinks for a custom post type for a site of mine stop working all of a sudden.

It wasn't a corrupt .htaccess file. (I'm running on nginx). Simply going to Settings->Permalinks and hitting "Save Changes" fixed the issue. Presumably because this rebuilt the rewrite_rules record in wp_options

But that doesn't explain WHY the rewrite_rules record stopped working to begin with.

I do use Easy Updates Manager to automatically update plugins when new versions are available. One theory I have is that a plugin update might be incorrectly firing a rewrite rule update - or a plugin update added a new post type but didn't flush rewrite rules.

I've had this occur on some sites that are very busy eCommerce websites running WooCommerce and it seems that permalinks settings are way too brittle to be so easily broken by bad plugin actors (assuming that's what triggered this to begin with).

Is there any way to ensure rewrite rules are never broken in this manner?

Thanks.

1 Answer 1

0

The answer is as simple as not helpful. You have plugins which have bad code, and in any complex system with many parts not controlled (at least not the code) by you, it will be very hard to debug how a global resource get corrupted.

The way to avoid it is to stop auto updating things, and properly test every update on a staging enviroment, so if something goes wrong and you might need to update the permalinks you will at least know that in advance.

2
  • Hey @Mark you are of course correct re: a staging site - for many of our sites we indeed operate this way - but there are some for which it's not commercially feasible for them - so auto updating plugins is a lesser evil than leaving them out of date. I'm interested in understanding what actions plugins could be doing which would corrupt rewrite_rules
    – Colm Troy
    Commented Jun 8, 2018 at 12:00
  • flush the rewrite rules for some reason, usually as a result of some DB structure change, while at the same time not regenerating the rewrite rule correctly. The flushing might happen in a different plugin than the one which fails regenerating its, so it might be hard to debug. If what I guess is correct, I don't thing there is much to be done about it except by visiting the permalink page is some automated way after a plugin upgrade was done. Commented Jun 8, 2018 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.