-
Notifications
You must be signed in to change notification settings - Fork 293
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
Prevent fatal error from sharing data being available for a non-existent module #5488
Comments
Thanks @nfmohit, your suggested approach would work, but let's adjust it slightly.
Let's use
Here we can simply use
Note we need the same check in the callback for |
Thank you for the kind and detailed review @aaemnnosttv! I've updated the IB according to your suggestions. |
Great, thanks! IB ✅ |
@makiost, could you update the QAB with more information?
For example,
|
…existing-modules Prevent fatal error from sharing data being available for a non-existent module.
QA Update ✅Verified :
cc @wpdarren |
See this Slack thread: We need to make sure that, if sharing data for a module which is no longer available is part of the sharing settings, submitting/modifying the sharing settings does not result in a fatal error. This currently happens for me consistently, because I have previously configured sharing settings for Idea Hub, but now disabled the module entirely (which can happen either through the
googlesitekit_available_modules
filter or in some cases feature flags).Screenshot:
The PHP fatal error I get is:
PHP Fatal error: Uncaught Exception: Invalid module slug idea-hub.
in/includes/Core/Modules/Modules.php:557
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
includes/Core/Modules/Modules.php
:module_exists()
which accepts the parameter$slug
.get_module( $slug )
in a try/catch block returningtrue
if it doesn't throw, andfalse
if it does (similar to theis_module_connected()
method).array_walk
callback for both'add_option_' . Module_Sharing_Settings::OPTION
and'update_option_' . Module_Sharing_Settings::OPTION
action hooks' callbacks, before getting the module data, do a check if the module exists using the newmodule_exists()
method. Execute the remaining code only if the module exists:site-kit-wp/includes/Core/Modules/Modules.php
Line 369 in dbb1fe1
site-kit-wp/includes/Core/Modules/Modules.php
Line 394 in dbb1fe1
Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: