WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#4702 closed defect (bug) (fixed)

Fatal error when making child category

Reported by: Viper007Bond Owned by: ryan
Milestone: 2.3 Priority: highest omg bbq
Severity: blocker Version: 2.3
Component: Administration Keywords: has-patch 2nd-opinion
Focuses: Cc:
PR Number:

Description

Go to Manage -> Categories and try to make a new category that's the child of another category. Doing so will produce the following error:

Catchable fatal error: Object of class stdClass could not be converted to string in [...]\wp-includes\taxonomy.php on line 765

Editing a category and turning it into the child of another also causes this issue.

Props to Ryan Fitzer for finding the issue.

Attachments (1)

4702.001.diff (760 bytes) - added by markjaquith 12 years ago.
Accept $parent as object or int

Download all attachments as: .zip

Change History (7)

#1 @Viper007Bond
12 years ago

PHP v5.2.1, MySQL v5.0.37

#2 @markjaquith
12 years ago

I get:

Catchable fatal error: Object of class stdClass could not be converted to string in [...]/wp-includes/taxonomy.php on line 647

Both lines are $wpdb->query() calls.

@markjaquith
12 years ago

Accept $parent as object or int

#3 @markjaquith
12 years ago

  • Keywords has-patch 2nd-opinion added
  • Owner changed from anonymous to ryan

There's my swing at it... but I don't know if the error is that these functions don't accept term objects as well as ints or if the error is that these functions are being passed parent term objects. I opted for the more liberal case and accepted either. Would like to get Ryan's feedback on this one as this is his code.

#4 @ryan
12 years ago

Let me look through the code, I don't remember intending it to take objects.

#5 @ryan
12 years ago

The call to get_category in wp_insert_category take the category ID as a ref. It then assigns the retrieved object to it, thus changing the id to an object. That ref is pretty useless. Let's remove it. Also, category_exists would be a better way to check the cat.

#6 @ryan
12 years ago

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

(In [5938]) Don't pass cat as ref. Fix some term sanitization. fixes #4702

Note: See TracTickets for help on using tickets.