Skip to content
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

Add $plugin to the list of global variables that shouldn't be overridden #1754

Merged
merged 1 commit into from Jul 1, 2019
Merged

Add $plugin to the list of global variables that shouldn't be overridden #1754

merged 1 commit into from Jul 1, 2019

Conversation

johnbillion
Copy link
Member

If a plugin overrides the $plugin global, things can break. See Rarst/laps#35.

This variable is missing from the list of global WP variables.

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified and approved.

For future reference:
The variables is declared by WP in the global namespace in https://core.trac.wordpress.org/browser/trunk/src/wp-settings.php#L361-374 and unset() straight after the loop finishes.

A variable override of this variable will only cause a problem if the plugin being loaded declares the $plugin variable in the global namespace in the initial file being loaded - or in any plugin files being loaded directly when the initial file is read.

@jrfnl jrfnl merged commit 6994433 into WordPress:develop Jul 1, 2019
@jrfnl jrfnl added this to the 2.x Next milestone Jul 1, 2019
@jrfnl jrfnl added Focus: WP interoperability Doing things the WP way, prefer using WP functionality over userland/PHP native Type: Enhancement labels Jul 1, 2019
@Rarst
Copy link
Contributor

Rarst commented Jul 1, 2019

Note that the same issue extends to $network_plugin and $mu_plugin. This is more noticeable now since starting with WP 5.1 these pass through new hooks, though they were never a good idea to override.

@jrfnl
Copy link
Member

jrfnl commented Jul 1, 2019

@Rarst Thanks for the heads-up. PRs for this are welcome 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus: WP interoperability Doing things the WP way, prefer using WP functionality over userland/PHP native Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants