WordPress / wp-autoupdates

Feature plugin building a UI for opting-in to plugin, theme, and core auto-updates.
https://wordpress.org/plugins/wp-autoupdates/
GNU General Public License v2.0
56 stars 18 forks source link

Wrong update message when using search filter in plugin table #129

Closed kebbet closed 4 years ago

kebbet commented 4 years ago

Hi If I search in the plugin view (which filters all plugins) and press “Enable auto-updates” for a plugin the message above the table is incorrect, and the search is reset. The message says “Plugin will no longer be auto-updated.” even though i enabled the auto-update feature. Test done with plugin version 0.8

  1. Go to 'wp-admin/plugins.php'
  2. Search for any plugin that reduces the view.
  3. Click ”Enable auto-update”
  4. Wrong message above table, and search is reset.
pbiron commented 4 years ago

Thank you for the report. I am able to reproduce this.

There are actually 2 things going on:

  1. when the search results are displayed, the Enable/Disable links are no longer being handled by Ajax. That is why the admin notice is then disabled when those links are clicked on after a search, instead of the link text (and some of the link attributes) being updated as happens when no search is done

  2. when the Enable link are not handled by Ajax, you are correct that an incorrect admin notice is shown (auto-updates are correctly enabled, it is just the admin notice that is wrong)

Number 2 is easy to fix, I'll do a PR for in a few minutes.

Number 1 is a harder to deal with, and will take some time figure out a solution.

Again, thanx for reporting this!!

pbiron commented 4 years ago

A few other points:

  1. this problem does not happen on the multisite themes screen a. the search results on this screen are not output via Ajax, so there is no problem with the auto-update Enable/Disable links being bound to Ajax actions

  2. there appears to be a bug in core with the shinny updates code (which handles the Ajax aspects of searches on the plugins screen) a. when an update is available for a plugin and that plugin appears in the search results, the "update" row does not appear in the search results

Before Search

before-search

After Search

after-search

I'll open a trac ticket about the shinny updates bug.

It is possible that in fixing that bug in core, we can make it easier to fix the problem with the Enable/Disable no longer being bound to Ajax actions after a search has been done.

pbiron commented 4 years ago

Here's the trac ticket: https://core.trac.wordpress.org/ticket/50170

azaozz commented 4 years ago

When the search results are displayed, the Enable/Disable links are no longer being handled by Ajax.

Happens because the whole list-table is replaced with the search results. So the click handler is no longer bound to td.column-auto-updates (as it is a new node). This is pretty easy to fix, need to bind the click handler to a "lower level" element, usually document. Can add to https://github.com/WordPress/wp-autoupdates/pull/130.

pbiron commented 4 years ago

Fixed in #130