Make WordPress Core

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#42692 closed defect (bug) (wontfix)

Unused static variable $column_headers

Reported by: jlambe's profile jlambe Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: close
Focuses: administration Cc:



We're working on a custom WP_List_Table class. For a project, we have setup a custom admin page and attach it to a custom post type.

Basically we call the add_submenu_page and set its parent slug to edit.php?post_type=custom_post_slug.

Our custom list table class is called CurrencyListTable and just displays a list of currencies coming from a custom database table. For this table, we have defined 2 custom columns. We correctly extend the get_columns() method and return an array with those 2 columns.

Expected result

On our page display fallback, we instantiate our custom table class and call its prepare_item(), search_box() and display() methods in order to render our list table.

We expect to see the usual list table with the table header and footer, the rows containing 20 items as our $per_page definition, the search box and the table pagination.


Everything is displayed on screen except the header, footer and rows of the table. The search box, pagination and total number of items is correctly displayed.


We have digged into the WordPress source code and stop our attention on the get_column_headers() function defined into the wp-admin/includes/screen.php file line 19.

When we remove the static definition for the $columns_header variable on line 23, our custom table renders correctly.

Perhaps a core developer could provide more information on why this variable is set as static.

We can see that the get_column_headers() function is called several times when rendering a list table and that we might want to re-use the set variable. But we don't understand why the first initialization is incorrect and set our column headers as an empty array.

When removing the static definition, everything works as expected. We have tested this with another custom set of people data where we have 114589 rows and haven't noticed any slow performance (we still show 20 rows per page).

Core list tables also work as expected for posts, pages, plugins, users, ...

Personnaly I think we can remove the static keyword as the WP_List_Table class get_column_info() method is storing the list of columns for a table instance into its "private" property $_column_headers. But I would like more insights from core developers before diggin into a patch.

Attachments (1)

wordpress_list_table_issue.jpg (186.9 KB) - added by jlambe 7 years ago.
Screenshot of the issue.

Download all attachments as: .zip

Change History (7)

7 years ago

Screenshot of the issue.

#1 @jlambe
7 years ago

  • Keywords close added

Without removing the static keyword, we were able to draw the table correctly by using an action hook load-{$page_hook} from the wp-admin/admin.php file.

When rendering our page with the later hook $page_hook, the issue persists. Because of the requirement of the admin header php file, we were not sure we could use the hook and trigger errors by rendering some content too early in the process.

I still would like some insights on this but the issue can be closed.

#2 @Presskopp
7 years ago

  • Keywords dev-feedback added

#3 @pento
5 years ago

  • Version trunk deleted

This ticket was mentioned in Slack in #core by noisysocks. View the logs.

4 years ago

#5 @talldanwp
4 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Hi @jlambe, this ticket was mentioned during a triage session in slack ( None of us present were particularly familiar with this bit of code, but I found the relevant changes in the project history which might shed some light.

This is the commit:

And here is the ticket for the change: #18785

It seems as though there was a need to retain backward compatibility, which may be why the variable is marked as static.

Last edited 4 years ago by SergeyBiryukov (previous) (diff)

#6 @SergeyBiryukov
4 years ago

  • Component changed from General to Administration
Note: See TracTickets for help on using tickets.