WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#25464 closed defect (bug) (fixed)

Function no_items() returns only one result

Reported by: pavelevap Owned by: ocean90
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.8
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description

Function no_items() is called here:
/wp-admin/includes/class-wp-list-table.php -> line 810
But only when $this->has_items() returns false.

And function no_items() is defined here:

1) /wp-admin/includes/class-wp-ms-themes-list-table.php -> line 162
There is no need for condition because only string "No themes found" will be shown everytime.

2) /wp-admin/includes/class-wp-plugins-list-table.php -> line 167
There is no need for condition because only string "You do not appear to have any plugins available at this time." will be shown everytime.

I am not sure if we should only remove not used strings or make also other logic fixes.

Attachments (1)

25464.patch (6.7 KB) - added by jbkkd 8 years ago.

Download all attachments as: .zip

Change History (6)

#1 @nacin
8 years ago

  • Component changed from General to Administration
  • Keywords needs-patch added

#2 @jbkkd
8 years ago

  • Keywords dev-feedback 2nd-opinion added

Apparently this function is being defined in multiple places all over, but only used in two files:
/wp-admin/includes/class-wp-themes-list-table.php, line 122
/wp-admin/includes/class-wp-list-table.php, line 854.

I think removing the other usages would be quite safe. Attaching a patch for that

@jbkkd
8 years ago

#3 @chriscct7
6 years ago

  • Keywords 2nd-opinion removed

#4 @ocean90
6 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to ocean90
  • Status changed from new to accepted

MS Themes List Table: It uses $this->has_items which is ! empty( $themes['all'] ), which is not the same as ->has_items(). Actually, I think the logic is inverted here, it should display "No themes found." if the search result is empty, not "You do not appear to have any themes available at this time.".

Plugins List Table: It uses !empty( $plugins['all'] ) to display "No plugins found." for empty search results. If there are no plugins at all it displays "You do not appear to have any plugins available at this time.". That seems to be right.

#5 @ocean90
6 years ago

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

In 34873:

MS Themes List Table: Fix inverted logic for displaying the "No items" message.

Fixes #25464.

Note: See TracTickets for help on using tickets.