Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#4499 closed defect (bug) (fixed)

Equality checks in query.php can break permalinks

Reported by: agharbeia Owned by: markjaquith
Priority: high Milestone: 2.3
Component: General Version: 2.2
Severity: major Keywords: has-patch
Cc: Focuses:

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)

4499-trunk.diff (2.3 KB ) - added by markjaquith 19 years ago.
Patched based on Otto42's modified query.php file (for trunk)

Download all attachments as: .zip

Change History (10)

#1 @foolswisdom
19 years ago

  • Milestone2.3 (trunk)

#2 @agharbeia
19 years ago

  • Summary problem in permalinks consisting solely of date/time elementspermalink unresolvable when it consists solely of date/time elements

#3 @Otto42
19 years ago

  • Priority normalhigh
  • Severity normalmajor
  • Summary permalink unresolvable when it consists solely of date/time elementsEquality checks in query.php can break permalinks

This is due to all the instances in query.php where it's checking for things like this:

if ( '' != $q['hour'] ) ...

The empty string == zero, in php. Evidence:

<?php if ('' == 0) echo "equal"; else echo "not equal"; ?>

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.

#4 @rob1n
19 years ago

  • Milestone 2.3 (trunk)2.2.2

Should be a simple search+replace.

#5 @rob1n
19 years ago

  • Keywords needs-patch added

#6 @Otto42
19 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

@markjaquith
19 years ago

Patched based on Otto42's modified query.php file (for trunk)

#7 @markjaquith
19 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone 2.2.22.3 (trunk)
  • Owner changed from anonymous to markjaquith
  • Status newassigned

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?

#8 @Otto42
19 years ago

Looks good to me, mark. It may not fix all of the possibles of this issue, but it does fix the hour/minute/second ones.

#9 @markjaquith
19 years ago

  • Resolutionfixed
  • Status assignedclosed

(In [5848]) Allow for hour/minute/second values in the QS that evaluate as false (like 0). Props Otto42 and agharbeia. fixes #4499

Note: See TracTickets for help on using tickets.