Opened 17 years ago
Closed 17 years ago
#4499 closed defect (bug) (fixed)
Equality checks in query.php can break permalinks
Reported by: | agharbeia | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.3 | Priority: | high |
Severity: | major | Version: | 2.2 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
According to this http://wordpress.org/support/topic/122702,
there is bug in the way WP 2.2 handles permalinks consisting only of date/time elements.
The blog in which the problem manifests uses the permalink structure /%year%/%monthnum%/%day%/%hour%%minute%%second%
In this case WP fails to uniquely identify a post whose %hour% permalink tag resolves to zero, and resorts instead to displaying the archive page for the calendar day in which the post referred to by the permalink was published, which in turn means that is_single() will always resolve to false and that no single post page can ever be obtained.
Posts having anything other than zero in their %hour% of publication will resolve normally.
Please note that unlike some people might first assume, this permalink structure worked in versions before 2.2. WordPress was indeed able to handle permalink structures which do not have neither %post_id% nor %postname%
Attachments (1)
Change History (10)
#2
@
17 years ago
- Summary changed from problem in permalinks consisting solely of date/time elements to permalink unresolvable when it consists solely of date/time elements
#3
@
17 years ago
- Priority changed from normal to high
- Severity changed from normal to major
- Summary changed from permalink unresolvable when it consists solely of date/time elements to Equality checks in query.php can break permalinks
#6
@
17 years ago
Can't make a patch at the moment, however I made a modified copy of query.php, and the original poster says it works. It can be found here:
http://wordpress.pastebin.ca/579658
#7
@
17 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from 2.2.2 to 2.3 (trunk)
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
We have to fix it in trunk before we can even consider fixing it in 2.2.2
4499-trunk.diff
is a diff based on Otto42's modified query.php
Look good?
This is due to all the instances in query.php where it's checking for things like this:
The empty string == zero, in php. Evidence:
All these checks need to be changed from != to !== in order to test for identity instead of equality.
Note that he would get the same result for minute == 0 or second == 0 as well. There are also possibly other equality checks that can result in broken links like this.