[wp-hackers] url_to_postid() improvements
ryan at boren.nu
Mon Jun 27 19:15:22 GMT 2005
> As many people have noticed, url_to_postid() fails in many cases. It
creates false positives (suggesting a post ID for URIs that are not
posts) and false negatives (failing on legit post URIs).
> I spent some time identifying the cases that fail and patching the
url_to_postid() function to handle them.
> Some significant changes have been made in 1.6 SVN to the
> url_to_postid() function, but it still fails in many cases. I also
patched in my changes to that version of the function, but still, it
fails many tests.
> I've set up a page for testing of the 4 functions (220.127.116.11 version,
18.104.22.168 patched by me, 1.6 SVN version, and 1.6 SVN patched by me).
Hmm, url_to_post_id() in 22.214.171.124 and 1.6 should be the same. Regardless, I
gave a quick glance at your 1.6 changes and they look goood. I look over
them more when I get home tonight. Something that might help eliminate
false positives is changing this:
if ( !empty($query->post) )
to something like this:
if ( $query->is_single || $query->is_page )
Try integrating that into your 1.6 version of url_to_postid() if you think
it would be helpful. Also, I think some comments explaining the string
manipulations might be usful. The intent of our query whacking can be
hard to decipher at times.
More information about the wp-hackers