Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12245 closed defect (bug) (fixed)

Canonical Backtrace

Reported by: miqrogroove's profile miqrogroove Owned by: dd32's profile dd32
Milestone: 3.0 Priority: high
Severity: normal Version: 3.0
Component: Canonical Keywords: has-patch
Focuses: Cc:

Description

Disabled all plugins.

Hit path /?cat=1

WordPress throws this every time

[16-Feb-2010 04:44:34] PHP Notice:  Trying to get property of non-object in /wp-includes/taxonomy.php on line 2299
[16-Feb-2010 04:44:34] PHP Warning:  parse_url() expects parameter 1 to be string, object given in /wp-includes/canonical.php on line 152
[16-Feb-2010 04:44:34] PHP Notice:  Trying to get property of non-object in /wp-includes/taxonomy.php on line 2299
[16-Feb-2010 04:44:34] PHP Warning:  parse_url() expects parameter 1 to be string, object given in /wp-includes/canonical.php on line 152
[16-Feb-2010 04:44:34] PHP Warning:  Cannot modify header information - headers already sent by (output started at /wp-includes/taxonomy.php:2298) in /wp-includes/pluggable.php on line 868

I have a backtrace stub taxonomy.php there. The Notices are both during redirect_canonical().

Not sure if this is a Canonical issue or something going on in Taxonomy? I'll keep looking.

Attachments (2)

12245.diff (1.0 KB) - added by ShaneF 15 years ago.
12245.2.diff (1014 bytes) - added by miqrogroove 15 years ago.

Download all attachments as: .zip

Change History (12)

#1 @nacin
15 years ago

Fly-by debug: First one is we only check for WP_Error in get_term_link(), when get_term() may return null, get_term_by() may return false.

Second one is in redirect_canonical(), we're getting a return value of get_term_link() and not validating it a link, as it may be returning WP_Error, false, or null.

If the term doesn't exist, sounds like we should never get to this point, though.

#2 @miqrogroove
15 years ago

see [13091] $slug = get_query_var('category_name'); probably has no value for /?cat=1

#3 @ShaneF
15 years ago

  • Cc ShaneF added
  • Keywords has-patch added; needs-testing removed
  • Owner changed from markjaquith to ShaneF
  • Status changed from new to accepted

Attached is a patch.

@ShaneF
15 years ago

#4 @miqrogroove
15 years ago

standby, I'm going to write a version with get_queried_object() for comparison.

#5 @nacin
15 years ago

So this doesn't slip through, we should also fix get_term_link() to account for !$term in addition to is_wp_error($term).

#6 @miqrogroove
15 years ago

Two other problems so far:

  1. ShaneF's patch throws property of a non-object at $slug = $_category_obj->slug;
  1. My patch doesn't add any errors, but I'm getting gobs of Notices in category-template.php and no proper 404's with either solution.

#7 @miqrogroove
15 years ago

Wow that was a mess. There are at least three bugs here.

#12246 Canonical crash when WP_DEBUG is enabled.

#8948 Canonical redirection on invalid category ID

And as for the $slug bug, get_queried_object() does work gracefully. See 12245.2.diff.

@miqrogroove
15 years ago

#8 @dd32
15 years ago

  • Owner changed from ShaneF to dd32

#9 @miqrogroove
15 years ago

Changeset [13170] by dd32

2nd pass at Taxonomy Term canonicalisation. Fix get_term_link() to expect null|false

WP_Error failure from get_term() family. See #12245, #8948

#10 @miqrogroove
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Tested and /?cat=1 is fixed. Thank you dd32 :) All remaining issues are described by the tickets mentioned above.

Note: See TracTickets for help on using tickets.