Ticket #5661 (closed defect (bug): fixed)

Opened 1 year ago

Last modified 1 year ago

url_to_postid sometimes incorrectly doubles requested url

Reported by: filosofo Assigned to: anonymous
Priority: normal Milestone: 2.5
Component: General Version: 2.5
Severity: normal Keywords: url_to_postid wp_rewrite has-patch
Cc: filosofo

Description

This patch brings url_to_postid into line with the same rewrite rule-matching behavior as that in the parse_request method of WP.

To understand the problem---which has already been fixed in the parse_query method---suppose you have a page with the name blog/comments-preview

Among others, you have the following two rewrite rules:
blog/comments-preview/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$
...
(blog/comments-preview)(/[0-9]+)?/?$

The problem is that ( (! empty($url)) && (strpos($match, $url) === 0) ) returns true on the first rewrite rule, where $match is the rule and $url is blog/comments-preview, so $request_match becomes blog/comments-preview/blog/comments-preview instead of what it should stay as: blog/comments-preview

So when the foreach loop reaches the correctly matching rule, the second one above, it no longer matches, and url_to_postid returns false.

Attachments

rewrite_match.diff (0.5 kB) - added by filosofo on 01/14/08 03:46:11.

Change History

01/14/08 03:46:11 changed by filosofo

  • attachment rewrite_match.diff added.

01/14/08 21:44:08 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6614]) Don't double requested url in url_to_postid(). Props filosofo. fixes #5661