A proposal for “next generation” rewrites

Ryan McCue has written a proposal for the “next generation” of WordPress rewrites. It's lengthy, but a great read on an area of WordPress with a lot of room for improvement.

The rewrite system was initially designed to implement pretty permalinks, but has been used and abused for so much more since then. With modern plugins and web apps built on top of WordPress, it’s not uncommon to have pages that don’t need a main query, or need a specialised system of querying. As an example of this, the REST API infrastructure added in WordPress 4.4 doesn’t use the main query, as many of the endpoints don’t require querying posts at all.

While the usage of rewrites has developed, the internals of how URLs are handled internally hasn’t changed. The system is fundamentally still designed for the blog era of WordPress. It also predates a lot of the pieces of WordPress we take for granted, such as transients and object caching.

To address the problem, Ryan has proposed a three part feature project that could take place over a series of major releases.

  • Decouple rewrites from the query system
  • Refactor and rework the internals to make them testable
  • Rethink rewrite storage and remove flushing

This would be a big project with a lot of moving parts, and he's proposing it to go under the new feature project guidelines versus a feature plugin because he thinks it fits that system better. There are weekly meetings happening on Wednesdays if you want to be involved, and you can check out his post to see more depth on each of the proposed steps.