Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#55316 closed enhancement (fixed)

Counter for total plugins is not updated after a plugin is deleted

Reported by: mitogh's profile mitogh Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Plugins Keywords: needs-testing has-testing-info has-patch
Focuses: ui, administration Cc:

Description

Context

When a plugin is deleted, the total count is updated correctly on the left count, however, the total count is not updated correctly on the right count (as you can see on the screenshot) and by following the steps to replicate this problem.

Steps to replicate.

  1. Install any plugin
  2. Activate the plugin
  3. Go to the plugin lists
  4. Deactivate the plugin
  5. Observe the total count of active plugins
  6. Click on Delete and accept the prompt to remove it.
  7. Observe how the total count decreased by 1 but the total items count on the right was not modified after the plugin was deleted.

Attachments (9)

2022-03-03_19-17.png (172.0 KB) - added by mitogh 2 years ago.
55316.diff (916 bytes) - added by costdev 2 years ago.
Update item count upon plugin deletion. Do not commit this patch - it needs review for i18n.
Screenshot at Mar 04 15-32-01 before patch.png (96.2 KB) - added by azouamauriac 2 years ago.
before patch
Screenshot at Mar 04 15-52-01 after_patch_55316.png (123.0 KB) - added by azouamauriac 2 years ago.
After patch
Screenshot at Mar 04 15-55-36 after_patch_not_work_for_recent_active.png (84.6 KB) - added by azouamauriac 2 years ago.
After patch 'Recently Active' tab (it seems like patch does not work there )
Screenshot at Mar 04 15-55-36 after_patch_working_for_auto_disable.png (111.2 KB) - added by azouamauriac 2 years ago.
After patch; 'Auto-updates Disabled' tab (patch works)
55316.2.diff (1.0 KB) - added by costdev 2 years ago.
Patch updated to use the count of the current view. Still needs a refresh for i18n if anyone is familiar with this.
Screenshot at Mar 04 17-16-45 after_patch_2_recently_active_works.png (91.5 KB) - added by azouamauriac 2 years ago.
after patch 55316.2.diff; same result for following tab: 'Inactive', 'Auto-updates Disabled'. The patch works
55316.3.diff (2.3 KB) - added by costdev 2 years ago.
Patch updated with i18n.

Download all attachments as: .zip

Change History (26)

#1 @costdev
2 years ago

  • Milestone changed from Awaiting Review to 6.0
  • Type changed from defect (bug) to enhancement
  • Version 5.9.1 deleted

Reproc Report

Env

  • Web Server: Apache (Linux)
  • WordPress: 6.0-alpha-52448-src
  • Browser: Chrome
  • OS: Windows 10
  • Theme: Twenty Twenty-Two
  • Plugins: Enable Customizer

Steps to test

  1. Navigate to Plugins > Installed Plugins.
  2. Observe the total count of "All" plugins.
  3. Click on Delete and accept the prompt to remove it.
  4. Observe how the total count decreased by 1 but the total items count on the right was not modified after the plugin was deleted.

Results

  1. The count on the right is not updated. Issue reproduced. ✅

Milestoning for 6.0 and removing the version as this will have existed for quite some time.

@costdev
2 years ago

Update item count upon plugin deletion. Do not commit this patch - it needs review for i18n.

#2 @costdev
2 years ago

  • Keywords needs-testing has-testing-info needs-refresh added

Patch 55316.diff should update the item count when a plugin is deleted.

However, this does not account for i18n/rtl and will need some input from a developer familiar with this.

Steps to test:

  1. Navigate to Plugins > Installed Plugins.
  2. Observe the total count of "All" plugins.
  3. Click on Delete and accept the prompt to remove it.
  4. Observe how the total count decreased by 1 but the total items count on the right was not modified after the plugin was deleted.
  5. Apply 55316.diff.
  6. Run npm run build:dev.
  7. Navigation to Plugins > Installed Plugins.
  8. Do a hard refresh to ensure that scripts have been refreshed.
  9. Repeat steps 2-4. This time, the item count should decrease by 1 as expected.

@azouamauriac
2 years ago

After patch 'Recently Active' tab (it seems like patch does not work there )

@azouamauriac
2 years ago

After patch; 'Auto-updates Disabled' tab (patch works)

#3 @azouamauriac
2 years ago

Above some test result.

#4 @costdev
2 years ago

Thanks for the tests @azouamauriac!

The patch is changing the value to plugins.all.length.

That's why it looked like the patch worked in the Auto-updates Disabled test, when in fact it was a coincedence that All and Auto-updates Disabled were the same number. I've have another look at the patch.

Last edited 2 years ago by costdev (previous) (diff)

@costdev
2 years ago

Patch updated to use the count of the current view. Still needs a refresh for i18n if anyone is familiar with this.

#5 follow-up: @costdev
2 years ago

Patch updated if you have time to run more tests @azouamauriac

#6 @swissspidy
2 years ago

For proper i18n you'll need to use wp.i18n._n() together with wp.i18n.sprintf. Make sure wp-i18n is a dependency of the updates.js script if not already the case.

#7 @costdev
2 years ago

Thanks @swissspidy! I'll take a look at this now.

@azouamauriac
2 years ago

after patch 55316.2.diff; same result for following tab: 'Inactive', 'Auto-updates Disabled'. The patch works

#8 in reply to: ↑ 5 @azouamauriac
2 years ago

Replying to costdev:

Patch updated if you have time to run more tests @azouamauriac

Done! Patch works on my side.

#9 @costdev
2 years ago

Thanks @azouamauriac!

I'll work on i18n and try to get this patch ready for further testing.

@costdev
2 years ago

Patch updated with i18n.

#10 @costdev
2 years ago

  • Keywords needs-refresh removed

#11 @kebbet
2 years ago

  • Keywords needs-refresh added

Perhaps use _nx() in combination with number_format_i18n() instead of just _n()? That way a comment can be added that the items word in this case means plugins, and the counter is displayed in the locales number format.

https://developer.wordpress.org/reference/functions/_nx/
https://developer.wordpress.org/reference/functions/number_format_i18n/

#12 @kebbet
2 years ago

Sorry, the number function can not be used with JavaScript so just ignore that part of the ”suggestion ”.

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


2 years ago

This ticket was mentioned in PR #2540 on WordPress/wordpress-develop by kebbet.


2 years ago
#14

  • Keywords has-patch added; needs-refresh removed

#15 @kebbet
2 years ago

Linked PR uses _nx() in the JavaScript-file. Rest of it is ported from 55316.3.diff by @costdev.

#16 @peterwilsoncc
2 years ago

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

In 53124:

Plugins: Update item count when plugin deleted.

Update the item count, "N items", on the plugin list when a plugin is deleted. This matches the live updating of various other counts on the screen.

Props mitogh, costdev, azouamauriac, swissspidy, kebbet.
Fixes #55316.

Note: See TracTickets for help on using tickets.