Opened 6 years ago

Closed 6 years ago

#4702 closed defect (bug) (fixed)

Fatal error when making child category

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

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 6 years ago.
Accept $parent as object or int

Download all attachments as: .zip

Change History (7)

PHP v5.2.1, MySQL v5.0.37

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.

Accept $parent as object or int

  • 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.

comment:4   ryan6 years ago

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

comment:5   ryan6 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.

comment:6   ryan6 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.