Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#32466 closed defect (bug) (fixed)

List table: hidden columns return unnecessary empty items

Reported by: afercia's profile afercia Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.2
Component: Administration Keywords: has-patch
Focuses: javascript Cc:

Description

While investigating on List Tables, noticed the hidden columns (see get_hidden_columns()) returned, for example, this:

https://cldup.com/S8aLhJASWc.png

where the serialized array stored in the DB has 4 empty strings (going to break it in multiple lines for readability):

`a:8:{
  i:0;s:6:"author";
  i:1;s:10:"categories";
  i:2;s:4:"tags";
  i:3;s:8:"comments";
  i:4;s:0:"";
  i:5;s:0:"";
  i:6;s:0:"";
  i:7;s:0:"";
}`

Turns out the current jQuery selector targets also the table headers in the footer and they don't have an ID. Since we need just the table headers with an ID, and we can't predict if they will be the ones in the thead or the ones in the tfoot, the proposed patch changes the jQuery selector to target just the ones with an ID.
Stored value with the patch applied:

`a:4:{i:0;s:6:"author";i:1;s:10:"categories";i:2;s:4:"tags";i:3;s:8:"comments";}`

Attachments (2)

32466.patch (500 bytes) - added by afercia 10 years ago.
32466.2.patch (507 bytes) - added by afercia 10 years ago.

Download all attachments as: .zip

Change History (12)

@afercia
10 years ago

#1 @afercia
10 years ago

  • Keywords has-patch added

#2 @afercia
10 years ago

  • Milestone changed from Awaiting Review to 4.3

#3 @afercia
10 years ago

  • Owner set to afercia
  • Status changed from new to assigned

#4 @afercia
10 years ago

  • Keywords commit added

@afercia
10 years ago

#5 @afercia
10 years ago

Updated patch with coding standards.

#6 @wonderboymusic
10 years ago

  • Keywords commit removed
  • Owner changed from afercia to wonderboymusic

There's another piece to this, wp_ajax_hidden_columns() has to be rebooted to not explode on empty string, which will produce an array with one empty item.

#7 @wonderboymusic
10 years ago

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

In 32751:

In wp_ajax_hidden_columns(), don't explode() on an empty string.
In columns.hidden(), which lives in common.js, don't return items with no id.

This was resulting in options like manageedit-postcolumnshidden containing a serialized array with random empty items.

Props afercia, wonderboymusic.
Fixes #32466.

#8 @wonderboymusic
10 years ago

In 33342:

Revert [32466], I will pick this up in 4.4.

See #32466.

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


10 years ago

Note: See TracTickets for help on using tickets.