Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#25852 closed defect (bug) (fixed)

Saving term broken. If no term parent is set - sets to term ID 1.

Reported by: mattheu Owned by: SergeyBiryukov
Priority: normal Milestone: 3.8
Component: Taxonomy Version: 3.8
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

This was introduced by the fix for ticket #17646

When saving a term with no parent selected - the parent is saved as term 1. It should be set to 0. For non-category terms - this causes them to dissapear from the admin.

From category-template.php line 346 - The term parent select field uses -1 for none - and this is now cast to 1 by the sanitize_term_field function - which saves the term parent as 1.

I've added a patch that sets any negative values to 0.

Attachments (3)

25852.diff (575 bytes ) - added by mattheu 13 years ago.
25852-2.diff (381 bytes ) - added by mattheu 13 years ago.
25852.3.diff (1.9 KB ) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (7)

@mattheu
13 years ago

#1 @SergeyBiryukov
13 years ago

  • Component GeneralTaxonomy
  • Milestone Awaiting Review3.8
  • Versiontrunk

@mattheu
13 years ago

#2 @mattheu
13 years ago

Updated patch to not use a ternary operator

#3 @SergeyBiryukov
13 years ago

25852-2.diff would not work as expected, since $value is already changed to 1 in line 1714. The check should also be inside the in_array() condition, not after it.

25852.3.diff reverts that part of [26010] and adds a basic unit test.

#4 @SergeyBiryukov
13 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 26028:

A negative term parent value should be sanitized to 0, not 1. Fix a regression in sanitize_term_field() caused by [26010].

props mattheu for initial patch.
fixes #25852.

Note: See TracTickets for help on using tickets.