Make WordPress Core

Opened 7 weeks ago

Last modified 8 days ago

#51256 reviewing defect (bug)

Duplicate HTML IDs for checkboxes in Plugins list table

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch
Focuses: administration Cc:


Background: #49916

If you have two plugins with the same name, but in different directories, the corresponding checkboxes on Plugins screen have duplicate ID attributes:

[DOM] Found 2 elements with non-unique id #checkbox_a55f1e83ab4fee1b42772d08e9971a9c: (More info: https://goo.gl/9p2vKq) 
<input type="checkbox" name="checked[]" value="debug-bar/debug-bar.php" id="checkbox_a55f1e83ab4fee1b42772d08e9971a9c">
<input type="checkbox" name="checked[]" value="debug-bar-old/debug-bar.php" id="checkbox_a55f1e83ab4fee1b42772d08e9971a9c">

Something like [48374] should be implemented for these checkboxes too.

Attachments (3)

51256.patch (1.5 KB) - added by kishanjasani 7 weeks ago.
Add a validation to restrict same ID generation
51256.2.patch (821 bytes) - added by mukesh27 6 weeks ago.
Patch with different solution.
51256.3.diff (806 bytes) - added by Hareesh Pillai 8 days ago.

Download all attachments as: .zip

Change History (12)

7 weeks ago

Add a validation to restrict same ID generation

#1 @kishanjasani
7 weeks ago

  • Keywords has-patch added

#2 @SergeyBiryukov
7 weeks ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @mukesh27
7 weeks ago

I have tested patch but it is not working for me it show me Array in id attribute.

#4 @kishanjasani
7 weeks ago

@mukesh27 It's working for me. I have tested it on ubuntu 18.04. can you please attach screenshot which output array you are getting in ID attribute? So, I can go further to improve my code.

Last edited 7 weeks ago by kishanjasani (previous) (diff)

#5 @mukesh27
6 weeks ago

@kishanjasani I have checked patch and it working fine now for me.

I have another approach for the solution. We can use $plugin_id_attr variable because it will use unique plugin id.

6 weeks ago

Patch with different solution.

#6 @kishanjasani
6 weeks ago

Yes, we can use that too. If the id value variable name doesn't matter.

#7 @Hareesh Pillai
8 days ago

  • Keywords needs-refresh added

Failing to apply the patch cleanly. Marking for refresh.

#8 @Hareesh Pillai
8 days ago

  • Keywords needs-refresh removed

Sharing the test results -

Before patch:

<input type="checkbox" name="checked[]" value="debug-bar/debug-bar.php" id="checkbox_7723712c996358d091e67d12c55e0c79">
<input type="checkbox" name="checked[]" value="debug-bar-old/debug-bar.php" id="checkbox_7723712c996358d091e67d12c55e0c79">

After patch:

<input type="checkbox" name="checked[]" value="debug-bar/debug-bar.php" id="checkbox_3181a37392941a47d4bf52bcd57f8c31">
<input type="checkbox" name="checked[]" value="debug-bar-old/debug-bar.php" id="checkbox_197a0c40d6f1064ea9fb5f9fa449cc19">

#9 @kishanjasani
8 days ago

@hareesh-pillai same patch is already added by @mukesh27.

Note: See TracTickets for help on using tickets.