Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#32339 closed defect (bug) (fixed)

Wrong logic for adding category in Press This

Reported by: pavelevap's profile pavelevap Owned by: azaozz's profile azaozz
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.2
Component: Press This Keywords:
Focuses: administration Cc:

Description

I noticed some strange behaviour and it seems to me, that logic is wrong.

https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-admin/includes/class-wp-press-this.php#L209

$cat_id will never return error, because it will be always array with term_id and term_taxonomy_id (existed term or created term).

Attachments (1)

Press_This_adding_new_category.jpg (26.9 KB) - added by pavelevap 9 years ago.

Download all attachments as: .zip

Change History (9)

#1 @kraftbj
9 years ago

  • Focuses administration added
  • Version changed from trunk to 4.2

#2 @kraftbj
9 years ago

  • Keywords reporter-feedback added

What was the strange behavior? In either case with the logic, want to make sure the strange behavior is either expected, but perhaps odd, or straight up a bug :)

#3 @pavelevap
9 years ago

@kraftbj: Sure. I could add new category several times to post. See attached screenshot. So, check for term existence does not work...

#4 @stephdau
9 years ago

If you check in your category list, all those entries will map to only one and the same category once first added, despite what it looks like. The back-end logic is accurate. The front-end logic could be improved.

#5 @pavelevap
9 years ago

Yes, this category is not created several times, but it can be confusing.

But following line will never be executed because $cat_id will never return error:

https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-admin/includes/class-wp-press-this.php#L209

And that is the cause of this problem?

#6 @pavelevap
9 years ago

  • Keywords reporter-feedback removed

#7 @azaozz
9 years ago

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

In 32827:

Press This: show error message when the user is attempting to add a category that already exists.
Fixes #32339.

#8 @samuelsidler
9 years ago

  • Milestone changed from Awaiting Review to 4.3
Note: See TracTickets for help on using tickets.