Opened 4 months ago
Closed 3 months ago
#64288 closed defect (bug) (fixed)
Deactivate link is active for plugins required by others when searching
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | 6.5 |
| Component: | Upgrade/Install | Keywords: | has-patch |
| Focuses: | administration | Cc: |
Description
Tested version: 6.9-RC2-61266
The "Deactivate" link on the plugins list is inactive if there's another active plugin that requires that one.
For example, my "Shop as Client Pro" is a paid plugin that requires the free wordpress.org "Shop as Client" plugin, so when both are active, the "Deactivate" link on "Shop as Client" is inactive. This is because I've declared "shop-as-client" on the main PHP file "Requires Plugins" header.
https://snipboard.io/cBZGDe.jpg
I just found out that when you perform a search on the plugins page, this is not the case: https://snipboard.io/qOUQlk.jpg
As you can see on the screenshot above, it also does not show the "Required by" and "Requires" sections below the description of each plugin.
This only happens when the search is performed by ajax, because if you refresh the page after the search is performed, you get the same plugin results, but the list has the correct "Deactivate" link status and shows the required plugins.
Attachments (1)
Change History (12)
#1
@
4 months ago
- Focuses administration added
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 7.0
- Version changed from trunk to 6.5
This ticket was mentioned in PR #10547 on WordPress/wordpress-develop by @hbhalodia.
4 months ago
#2
- Keywords has-patch added; needs-patch removed
- Update the
wp_ajax_search_pluginsaction function to initialize theWP_Plugin_Dependenciesclass to correctly identiy the plugin dependency when plugin search.
Trac ticket: https://core.trac.wordpress.org/ticket/64288
#3
@
4 months ago
Hi Team, I do have found the root cause for the issue. The thing is WP_Plugin_Dependencies::initialize(); is not being initialized in Ajax instance, hence the required dependencies are being identified as empty. In order to fix this, we just need to update the search plugins ajax call, wp_ajax_search_plugins to initialize the WP_Plugin_Dependencies::initialize(); class and then it would work as expected. Below is the demo video, how the fix is working as expected.
#4
@
4 months ago
Patch Summary
This patch ensures that plugin dependency metadata is properly loaded when performing an AJAX plugin search. The AJAX endpoint wp_ajax_search_plugins() was not calling WP_Plugin_Dependencies::initialize(), which caused dependency-aware action links (e.g., disabling “Deactivate”) to behave incorrectly during filtered views.
Technical Details
The normal (non-AJAX) plugins list initializes dependencies during page load, but the AJAX callback does not. As a result, the dependency graph is unavailable in the AJAX context, causing incorrect display of action links in search results.
The patch inserts WP_Plugin_Dependencies::initialize() before calling $wp_list_table->prepare_items().
#5
@
4 months ago
I tested this on my setup. Before the patch, the Deactivate button was still active in the search results, and the dependency message didn’t show.
Please refer below screenshot for before results:-
https://prnt.sc/pCvVWEKBskki
After applying the patch, everything works correctly — the Deactivate button is disabled and the ‘Required by’ text appears in the search view.
Please refer below screenshot for after results:-
https://prnt.sc/pktk4VIdbBnl
@westonruter commented on PR #10547:
4 months ago
#7
This fixes the issue for me!
Before:
https://github.com/user-attachments/assets/f5b58b39-2e4d-42f7-92da-c46d02812d56
After:
https://github.com/user-attachments/assets/df71bc27-a6cb-417a-bba2-7761284f6cf0
@westonruter commented on PR #10547:
4 months ago
#8
The WP_Plugin_Dependencies::initialize() method is otherwise currently being called on:
src/wp-admin/plugins.phpsrc/wp-admin/plugin-install.php- The
validate_plugin_requirements()function - The
WP_Plugin_Dependencies::check_plugin_dependencies_during_ajax()method.
This last one indicates that it “Checks plugin dependencies after a plugin is installed via AJAX.” This is registered here:
Question: Would it not make sense to hook in similarly for the search-plugins ajax action? I suppose ultimately the same effect is done since WP_Plugin_Dependencies::initialize() is added to wp_ajax_search_plugins(). The check_plugin_dependencies ajax action was added separately for plugin dependencies, whereas wp_ajax_search_plugins() already existed, to which WP_Plugin_Dependencies::initialize() can be added in the same way it was added top-level to the plugins.php and plugin-install.php admin screens.
@hbhalodia commented on PR #10547:
4 months ago
#9
Hi @westonruter, Thanks for reviewing the PR.
Yes, I agree that this should get initialized in the Ajax context, as it already being done for,
Ultimately for search-plugins, ajax this should get initialized to correctly identify the plugin dependency.
The "Required by" etc. notes below the plugin description also appear to be missing.