WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 17 months ago

#34564 new defect (bug)

WP_List_Table::get_column_info() inefficient

Reported by: bobbingwide Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Administration Keywords:
Focuses: Cc:

Description

Changes in 4.3 to add a default column have left the logic for get_column_info() very inefficent with get_primary_column_name() being called for every single row being displayed.

In my list table displaying 50 rows the list_table_primary_column filter was invoked 52 times. My get_columns() method was called 105 times.
and that meant that the gettext filter was invoked 105 times for each of the defined columns.

That's an awful lot of work for a field which is supposed to have been cached.

Here's the relevant part of the backtrace

0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik\libs\bwtrace.php:108 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\schunter\admin\class-schunter-list-table.php:74 0
2. get_columns C:\apache\htdocs\wordpress\wp-content\plugins\oik\admin\class-bw-list-table.php:871 0
3. get_default_primary_column_name C:\apache\htdocs\wordpress\wp-content\plugins\oik\admin\class-bw-list-table.php:898 0
4. get_primary_column_name C:\apache\htdocs\wordpress\wp-content\plugins\oik\admin\class-bw-list-table.php:936 0
5. get_column_info C:\apache\htdocs\wordpress\wp-content\plugins\oik\admin\class-bw-list-table.php:1007 0
6. print_column_headers() C:\apache\htdocs\wordpress\wp-content\plugins\oik\admin\class-bw-list-table.php:1099 1
7. display C:\apache\htdocs\wordpress\wp-content\plugins\schunter\admin\schunter.php:78 0 

Note: class-bw_list-table.php is basically a copy of class-list-table.php

The code in question is the new logic that doesn't trust $_column_headers, introduced in #25408.

Change History (1)

#1 @bobbingwide
5 years ago

I don't know what was wrong with the logic that checked the number of entries in $this->_column_headers.

Also, as a passing comment, I have no idea what 'horse reasons' is meant to mean.

Note: See TracTickets for help on using tickets.