Make WordPress Core

Opened 2 months ago

Closed 8 weeks ago

Last modified 3 days ago

#62504 closed defect (bug) (fixed)

Checking "Uncategorized" category adds all categories with an ID starting with 1

Reported by: ffffelix's profile ffffelix Owned by: azaozz's profile azaozz
Milestone: 6.7.2 Priority: normal
Severity: normal Version: 6.7.1
Component: Editor Keywords: has-patch has-testing-info fixed-major dev-reviewed
Focuses: javascript Cc:

Description

In the Classic Editor, checking the "Uncategorized" checkbox (tag ID 1) also checks/unchecks all categories with an ID where the first digit is 1 (e.g. 1, 10, 100, 1000).

New in 6.7.1, likely related to #62440.

Steps to reproduce in WordPress Playground:

  1. Activate Classic Editor plugin
  2. Create 11 categories – these will have IDs 2 through 12
  3. On post edit screen, check "Uncategorized" checkbox
  4. All categories with ID starting with a "1" are checked

Attachments (3)

categories.mp4 (147.2 KB) - added by ffffelix 2 months ago.
Demo
wp-fix-62504-v2.zip (22.3 KB) - added by azaozz 2 months ago.
wp-fix-62504-v3.zip (22.1 KB) - added by azaozz 7 weeks ago.

Download all attachments as: .zip

Change History (46)

@ffffelix
2 months ago

Demo

This ticket was mentioned in PR #7863 on WordPress/wordpress-develop by @ffffelix.


2 months ago
#1

  • Keywords has-patch added

Fixes category checkboxes in v6.7.1.

This change makes matching the desired tag ID to its checkbox elements more strict.

Example: when selecting a category with an ID of 1, the jQuery selector would also match the checkboxes for any category with an ID starting 1 (e.g. 10, 110, 1043).

The checkbox IDs are output via wp_unique_prefixed_id so should always have a trailing slash after the ID.

Trac ticket: https://core.trac.wordpress.org/ticket/62504

#2 @ffffelix
2 months ago

After further testing, an additional requirement to trigger the bug is that the inital clicked category must be in both the "All categories" and "Most used" lists — i.e. have more than one checkbox on the page.

#3 @desrosj
2 months ago

  • Milestone changed from Awaiting Review to 6.7.2

Thanks for this report, @ffffelix.

Moving to 6.7.2 to continue investigating.

#4 @azaozz
2 months ago

  • Keywords needs-testing added

Can reproduce it. Yes, the selector is too general, needs to be stricter. The PR seems to fix it here but better to test it more.

@ironprogrammer commented on PR #7863:


2 months ago
#5

Thanks for the patch, @ffffelix!

I was also able to reproduce this issue by unchecking and re-checking "Uncategorized" (used https://playground.wordpress.net/#{%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22features%22:{%22networking%22:true},%22login%22:true,%22landingPage%22:%22/wp-admin/post.php?post=1&action=edit%22,%22preferredVersions%22:{%22php%22:%228.0%22,%22wp%22:%226.7.1%22},%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginData%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22classic-editor%22}},{%22step%22:%22wp-cli%22,%22command%22:%22wp%20term%20generate%20category%20--count=11%22}} this Playground link] that generates the terms).

To test the patch, the default Playground link works fine if you go through the repro set up steps. But https://playground.wordpress.net/?core-pr=7863#{%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22features%22:{%22networking%22:true},%22login%22:true,%22landingPage%22:%22/wp-admin/post.php?post=1&action=edit%22,%22preferredVersions%22:{%22php%22:%228.0%22,%22wp%22:%226.7.1%22},%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginData%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22classic-editor%22}},{%22step%22:%22wp-cli%22,%22command%22:%22wp%20term%20generate%20category%20--count=11%22}} try out this one] that combines the repro test with the PR (takes longer to load in order to build the PR patch).

These links will look kinda nasty in Trac, but I'll share a formal test report there.

#6 @ironprogrammer
2 months ago

  • Keywords has-testing-info added

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/7863

Environment

  • Playground (see this PR comment for repro and patch testing links)
  • PHP: 8.0
  • WordPress: 6.7.1
  • Active Plugins:
    • Classic Editor 1.6.5

Actual Results

With Classic Editor active for the post:

  • ✅ Checking the "Uncategorized" category does not automatically check categories with IDs beginning with 1.
  • ✅ With categories whose IDs begin with 1 checked, unchecking the "Uncategorized" category does not automatically uncheck them.

Confirmed issue does not surface with block editor active for post.

#7 @ironprogrammer
2 months ago

#62508 was marked as a duplicate.

#8 @neotrope
2 months ago

We see this behavior also (you got ticket up a few ahead of me). In our case, using PHP 7.4x, 6.7.1; classic editor; we see random batches of pre-selected categories. We don't have uncategorized cat as not normal for a news portal :) So, we see main cats, and sub-cats selected. Like, more than 25+ selected and only fix is going into category selector and manually 'unchecking.' So, pre checked "business," "Florida" "California --> San Diego," "Medical" etc.

Folks are on top of this already it looks like, just adding to the foam and fray. :)

#9 @neotrope
2 months ago

Our issue - initial start post, no items selected, then upon selecting item, huge number of items get selected.

#10 @azaozz
2 months ago

wp-fix-62504.zip is a hotfix plugin that replaces the post.js file with a fixed version. If it works well this code will probably be added to the official WordPress hotfix plugin.

Please test!

#11 @narenin
2 months ago

Test Report

Patch tested: https://core.trac.wordpress.org/attachment/ticket/62504/wp-fix-62504.zip

Environment
PHP: 8.0
WordPress: 6.7.1
Active Plugins:
Classic Editor 1.6.5
Actual Results
With Classic Editor active for the post:

✅ When we are checking the "Uncategorized" category it does not automatically check categories with IDs beginning with 1.
✅ Also, with categories whose IDs begin with 1 checked, unchecking the "Uncategorized" category does not automatically uncheck them.

This ticket was mentioned in Slack in #core-test by zunaid321. View the logs.


2 months ago

#13 @zaoyao
2 months ago

Tested link

https://playground.wordpress.net/?core-pr=7863#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22features%22:%7B%22networking%22:true%7D,%22login%22:true,%22landingPage%22:%22/wp-admin/post.php?post=1&action=edit%22,%22preferredVersions%22:%7B%22php%22:%228.0%22,%22wp%22:%226.7.1%22%7D,%22steps%22:%5B%7B%22step%22:%22installPlugin%22,%22pluginData%22:%7B%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22classic-editor%22%7D%7D,%7B%22step%22:%22wp-cli%22,%22command%22:%22wp%20term%20generate%20category%20--count=11%22%7D

Environment
PHP: 8.0
WordPress: 6.7.1
Active Plugins:
Classic Editor 1.6.5
Actual Results
With Classic Editor active for the post:

When we select the "Uncategorized" category, categories with IDs starting with 1 are not automatically selected. Additionally, if categories with IDs starting with 1 are already checked, unchecking the "Uncategorized" category does not automatically uncheck them.

#14 @im3dabasia1
2 months ago

Reproduction Report

Description

This report validates whether the issue can be reproduced, but not exactly in the manner described above. In my case, additional categories 1 and 2 were selected.

Environment

  • WordPress: 6.7.1
  • PHP: 8.1.29
  • Server: nginx/1.16.0
  • Database: mysqli (Server: 8.0.16 / Client: mysqlnd 8.1.29)
  • Browser: Chrome 129.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.0
  • MU Plugins: None activated
  • Plugins:
    • Classic Editor 1.6.5
    • Test Reports 1.2.0

Actual Results

  1. ✅ Checking 'Uncategorized' selects other options (not the one suggested above, i.e., all with 1's). In my case, 1 and 2 were selected.

Supplemental Artifacts

Video https://jmp.sh/SSDFKPiK

#15 @cbravobernal
2 months ago

#62516 was marked as a duplicate.

#16 @cbravobernal
2 months ago

#62517 was marked as a duplicate.

#17 @whitedd
2 months ago

I have a problem with categories that start with the number 34 (34, 345, 341 etc.). This fix does not work in my case. I reverted to ver. 6.7 and now everything works as it should.

#18 @desrosj
2 months ago

#62529 was marked as a duplicate.

#19 @neotrope
2 months ago

[*WORKS*]
The hot pix used as WP plugin (not called directly for those who were confused on where to put it), worked for us in our situation. Now, when doing new post, clicking on 'business' or 'AP' no longer auto selects 40 other random cats and sub-cats in the category picker/seelctor box. We had no issue with 'uncategorized' as we always delete that.

THANKS @azaozz 

Last edited 2 months ago by neotrope (previous) (diff)

#20 @ironprogrammer
2 months ago

I've verified that the hotfix plugin shared in comment:10 addresses the issue. Thanks, @azaozz!

Test Report

Patch tested: attachment:wp-fix-62504.zip

Environment

Actual Results

With Classic Editor active for the post:

  • ✅ Checking the "Uncategorized" category does not automatically check categories with IDs beginning with 1.
  • ✅ With categories whose IDs begin with 1 checked, unchecking the "Uncategorized" category does not automatically uncheck them.

#21 @ironprogrammer
2 months ago

Reply to @im3dabasia1:

Thanks for sharing your testing details! Would you be able to confirm the initial digit(s) of the category whose selection causes other categories to be selected as well? What are the IDs of "Uncategorized", "cat 1", and "cat 2"?

For example, the first set of IDs in this example all begin with 1: 1, 10, 11, 12, and are caught up when the first is checked:

https://cldup.com/dOuqWiiN0o.png

#22 @ironprogrammer
2 months ago

Reply to @whitedd:

Would you please share how you tested the patch or hotfix plugin? It would help ensure that the patch addresses all variations of this issue. Thanks!

#23 @azaozz
2 months ago

Updated the hotfix plugin to only replace post.js in WP 6.7.1 and to check if another plugin has already replaced it. Also removed the old version of the plugin.

If you've downloaded the old hotfix, please update it!

#24 @azaozz
2 months ago

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

Committed the patch from the PR to trunk in [59454] but seems Trac has a bad day. Here's the commit on GitHub.

In: [59454]
Editor: Fix selecting/deselecting multiple unwanted categories when clicking on a Category checkbox on the old Edit Post screen.

Props ffffelix, desrosj, ironprogrammer, neotrope, narenin, zaoyao, im3dabasia1, cbravobernal, azaozz.
Fixes #62504.

Last edited 2 months ago by azaozz (previous) (diff)

#25 @azaozz
2 months ago

  • Keywords fixed-major added; needs-testing removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopen for 6.7.2.

Last edited 2 months ago by azaozz (previous) (diff)

#26 @neotrope
2 months ago

Thank you. Updated fix is working here. :)

#27 @narenin
2 months ago

#62540 was marked as a duplicate.

#28 @sabernhardt
2 months ago

#62555 was marked as a duplicate.

#29 @swissspidy
2 months ago

#62556 was marked as a duplicate.

#30 @swissspidy
8 weeks ago

#62567 was marked as a duplicate.

#31 @cbravobernal
8 weeks ago

#62580 was marked as a duplicate.

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


8 weeks ago

#33 @joemcgill
8 weeks ago

  • Keywords dev-reviewed added

@azaozz [59454] looks good to merge to the 6.7 branch.

#34 @azaozz
8 weeks ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from reopened to closed

In 59468:

Editor: Fix selecting/deselecting multiple unwanted categories when clicking on a Category checkbox on the old Edit Post screen.

Rewieved by joemcgill.
Merges [59454] to the 6.7 branch.

Props ffffelix, desrosj, ironprogrammer, neotrope, narenin, zaoyao, im3dabasia1, cbravobernal, azaozz.
Fixes #62504.

#35 @patrikmuse
8 weeks ago

#62599 was marked as a duplicate.

#36 @dhruvang21
7 weeks ago

#62625 was marked as a duplicate.

#37 @sabernhardt
7 weeks ago

#62625 was marked as a duplicate.

#38 @sabernhardt
7 weeks ago

#62618 was marked as a duplicate.

#39 @azaozz
7 weeks ago

Hi there is another version of the hotfix that fixes a problem with the translations. Please test!

#40 @pelstudio
4 days ago

This issue still persists in 6.7.1 with custom taxonomies

#41 @davidbaumwald
4 days ago

Confirmed this issue an issue with 6.7.1 and custom taxonomies(WooCommerce product_cat). Installed the v3 hotfix plugin, and it seems to have resolved the issue.

#42 @dhanendran
3 days ago

The latest patch doesn't seem to be fixing it as well. It uses the incomplete selectors. Id for the checkbox and li is in the format of {id}-1 or {id}-2. So we need to consider the last number as well.

We need to use below selector to fix this.

$('input#in-' + taxonomy + '-' + id + '-1' + ', input[id^="in-' + taxonomy + '-' + id + '-2"]')

#43 @davidbaumwald
3 days ago

@dhanendran Thanks for the report! Since the selector is using the starts with operator(^=), the fix in v3 should cover the case you mentioned, regardless of what comes after the last hyphen.

Note: See TracTickets for help on using tickets.