[wp-hackers] Any way to bypass $wp->query_posts()?

Mike Schinkel mikeschinkel at newclarity.net
Thu Apr 9 02:41:29 GMT 2009


"SoJ Web" <sojweb at indiana.edu> wrote:
> You intend to rewrite URL's without using pattern matching? 

I didn't say that? I plan to use pattern matching via a subset of URI Templates [1].

Regex is a general purpose pattern matching engine that can handle almost any pattern match possible. As such, it's overly complex and prone to unexpected side effects. OTOH URI Templates need only match valid URL patterns which is a much smaller valid set and much less prone to unexpected matching. FWIW, my plugin actual translates the URI Templates into RegEx, but those RegEx are run in PHP not in mod_rewrite and are constrained in their format. AND, and this is important, it all currently works and works elegantly. Problem is there are some rough edge cases that I'd to see cleaned up, and to clean them up requires some small mods to core.

> Regardless of whether you're using Apache or PHP, you still 
> end up using regular expressions for anything remotely 
> complicated. 

That's not necessarily true. One could use URI Templates for all matching if desired. I'm actually translating URI Templates into Regex because I'm trying to stick with WordPress conventions as much as I can, and that requires WP_Rewrite.

> But you missed my point. The point was to put a rewrite 
> directive before the WordPress directives so that your code, 
> instead of WordPress, could handle the request (and probably 
> with regex). 

I didn't miss your point, I stated that your suggested solution was an inappropriate architecture and a solution of last resort.  mod_rewrite is in general a hack for Apache's lack of a proper URL abstraction model. Application architecture should not be defined in mod_rewrite directives; it's just the wrong place for it to exist. The OSI model[2] was designed before the web became mainstream so it doesn't discussed a layer for the web server but in concept it's separation of layers it relevant here.
 
> Rewriting to specific file that handles the request is not sub-optimal. 
> If you think it is, stop using WordPress, because that's what it does.

WordPress uses a very general purpose mod_rewrite directive, and is not specific to any specific WordPress implementation.  Your suggestion is application-layer specific and "as an architecture" mod_rewrite should only be used if there is no other option.

Regarding your "stop using WordPress" comment, it's juvenile and I'm not going to honor that comment with a response.

Finally, you still don't explain what wrong with the "if" statement I proposed.

-Mike Schinkel
Custom Wordpress Plugins
http://mikeschinkel.com/custom-wordpress-plugins
[1] http://bitworking.org/projects/URI-Templates/
[2] http://en.wikipedia.org/wiki/OSI_model

P.S. Finally, why is this debate so important to you?  For me, I'm trying to get something accomplish that I need. For you? Does my getting something accomplished hurt you in any way?  Or does my assertion that mod_rewrite is suboptimal make you feel the need to defend your prior choices? If yes and it helps, I don't see anything wrong with your using mod_rewrite for a specific site, it's just as part of a general purpose architecture where I believe it is inappropriate.




More information about the wp-hackers mailing list