Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14061 closed defect (bug) (fixed)

Bugs in edit-tags and edit columns regarding post_type vars

Reported by: nacin's profile nacin Owned by:
Milestone: 3.0.1 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

Originally reported by Frumph on wp-testers. I additionally found the count column issue.

To reproduce the two things fixed by the patch:

  1. Add a 'tags' or 'categories' column to pages or a custom post type using the manage.*columns filters. The tag links to edit.php but it will not include the post type.
  1. Add a tag/term to edit-tags.php, and inspect the link in the post count column for the row added via AJAX. This is due to _tag_row() relying on a $post_type global that is set in edit-tags.php but not in admin-ajax.php. This part is a regression, but it's arguably minor.

Setting to 3.0.1 for now. There may be more bugs here based on Frumph's reports.

Attachments (1)

14061.diff (2.3 KB) - added by nacin 14 years ago.

Download all attachments as: .zip

Change History (8)

@nacin
14 years ago

#1 @shidouhikari
14 years ago

  • Cc shidouhikari added

Instead of

$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';

I'd use

$post_type = empty($_POST['post_type']) ? 'post' : $_POST['post_type'];

There's no need for the NOT, and ternary operator doesn't necessarily means

if(<sucessiful>) <success> else <default>

:P

#2 @nacin
14 years ago

In general, I would agree, but I like using !empty() however, as it functions kind of like ?: (omitting the middle, PHP 5.3+), with the middle being if the variable is indeed provided, and the end being the alternative if it is not. In fact we use this pattern throughout core and it is far easier to read/understand.

#3 @filosofo
14 years ago

According to the WordPress Coding Standards:

Ternary operators are fine, but always have them test if the statement is true, not false. Otherwise it just gets confusing.

#4 @nacin
14 years ago

I've seen that, and I'd argue that !empty() should be an exception, as it's testing something, if true uses something, if false uses an alternative. Checking for passed variables using isset() or !empty() is very common. Does anyone find the second example above less confusing than the first?

#5 @scribu
14 years ago

Related: #14089

#6 @nacin
14 years ago

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

(In [15336]) Make Categories/Tags columns on edit.php properly aware of post types. Also ensure AJAX add-tag on edit-tags.php is given the post type. fixes #14061 for trunk.

#7 @nacin
14 years ago

(In [15337]) Make Categories/Tags columns on edit.php properly aware of post types. Also ensure AJAX add-tag on edit-tags.php is given the post type. fixes #14061 for 3.0.

Note: See TracTickets for help on using tickets.