-
Notifications
You must be signed in to change notification settings - Fork 801
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
Autoloader: Avoid a PHP warning when an empty string is passed to is_directory_plugin()
.
#16442
Conversation
…_directory_plugin()`. Example Warning: `strpos(): Offset not contained in string`.
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16442 Scheduled Jetpack release: August 4, 2020. |
Thanks for the patch. We can't duplicate this on a brand new multisite with no local plugins activated in our initial look, so might just be some odd legacy w.org stuff going on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for the fix and the unit test!
I've never known the option to not contain an array either, so I really do suspect it's some ancient effect of some kind. I suspect it may have predated the |
Makes sense. Either way, 40 minutes without any warnings on w.org, so that's an approved review from me. Thanks for the assist! |
…s passed to `is_directory_plugin()`. (#16442) Co-authored-by: Brandon Kraft <[email protected]>
Cherry-picked to |
Updated the release branch to a new version of Jetpack Autoloader with that fix in 461b349 |
…s passed to `is_directory_plugin()`. (#16442) Co-authored-by: Brandon Kraft <[email protected]>
Autoloader: Avoid a PHP warning when an empty string is passed to
is_directory_plugin()
.Example Warning:
strpos(): Offset not contained in string
.Changes proposed in this Pull Request:
is_directory_plugin()
.Does this pull request change what data or activity we track or use?
No.
Testing instructions:
I'm not really sure how this has happened, but on WordPress.org
get_option( 'active_plugins' )
returns''
(an empty string) on some sites. I don't know if that's expected or not, but I suspect it only happens on sites that have never had a plugin activated on it directly, only through Network-activated plugins.It causes
get_active_plugin_paths()
https://github.com/Automattic/jetpack/blob/master/packages/autoloader/src/class-plugins-handler.php#L48-L52 to havearray( '' )
as it's$plugin_slugs
value, which seems like it might be expected due to it casting the option result to an array..I've included a unit test which covers at least the result of this.
An alternative patch could have been to perform an
array_filter()
over$plugin_slugs
first inget_active_plugin_paths()
but this seemed more defensive.Proposed changelog entry for your changes: