-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin suppression can fail to work during validate requests #6809
Comments
The issue is that the amp-wp/src/PluginSuppression.php Lines 107 to 123 in c2b9b38
Since it is running at |
I think amp-wp/includes/validation/class-amp-validation-manager.php Lines 1297 to 1302 in c2b9b38
|
(QA still necessary on 2.2 branch.) |
Bug Description
In a support topic I discovered that even though I suppressed Autoptimize, validation errors for it were still showing up when validating the page. However, they would not appear in the admin bar.
I found a way to replicate the issue with the following plugin:
With that plugin active and suppressed:
Going to an AMP page on the frontend shows no validation errors being detected:
However, if I go to the Validated URL screen then I see an error detected:
I believe it has to do with this logic in
AMP_Validation_Manager::wrap_hook_callbacks()
:amp-wp/includes/validation/class-amp-validation-manager.php
Lines 1463 to 1481 in c2b9b38
The replacement of the original callback with the wrapped callback closure I believe is interfering with
PluginSuppression::suppress_hooks()
specifically when it calls$this->is_callback_plugin_suppressed( $callback['function'], $suppressed_plugins )
:amp-wp/src/PluginSuppression.php
Lines 368 to 379 in c2b9b38
Since at this point
$callback['function']
may be the closure and not the original callable from the other plugin, the check fails because the AMP plugin is detected and not the Auto Add Script to Footer function.What's strange is that this issue specifically happens when the
wp
action is involved. If I change my test plugin as follows:Then the suppression works successfully.
Expected Behaviour
The plugin should be suppressed on the frontend and during a validate request.
Screenshots
No response
PHP Version
No response
Plugin Version
2.2
AMP plugin template mode
Transitional
WordPress Version
No response
Site Health
No response
Gutenberg Version
No response
OS(s) Affected
No response
Browser(s) Affected
No response
Device(s) Affected
No response
Acceptance Criteria
No response
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response
The text was updated successfully, but these errors were encountered: