#51728 closed defect (bug) (invalid)
Fix uninitialized variable wp_filter
Reported by: | mikaelmayer | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | trivial | Version: | 5.6 |
Component: | Plugins | Keywords: | has-patch |
Focuses: | Cc: |
Description
In the file wp-settings.php, there is this code:
// Re-initialize any hooks added manually by advanced-cache.php if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); }
However, $wp_filter is never set on a standard WordPress installation.
Therefore, a isset should be added, so that it does not trigger useless NOTICEs debug statements:
// Re-initialize any hooks added manually by advanced-cache.php if ( isset($wp_filter) ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); }
See the PR:
https://github.com/WordPress/wordpress-develop/compare/master...MikaelMayer:patch-1
Change History (6)
This ticket was mentioned in PR #706 on WordPress/wordpress-develop by MikaelMayer.
4 years ago
#1
github-actions[bot] commented on PR #706:
4 years ago
#2
Hi @MikaelMayer! 👋
Thank you for your contribution to WordPress! 💖
It looks like this is your first pull request, so here are a few things to be aware of that may help you out.
No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.
Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this one mirrors. But please feel free to use pull requests to work on any contribution you are making.
More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post.
Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.
If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.
The Developer Hub also documents the various coding standards that are followed:
- PHP Coding Standards
- CSS Coding Standards
- HTML Coding Standards
- JavaScript Coding Standards
- Accessibility Coding Standards
- Inline Documentation Standards
Please remember that the WordPress project is largely maintained by volunteers
Thank you,
The WordPress Project
MikaelMayer commented on PR #706:
4 years ago
#4
I was not able to reproduce the error, probably something got corrupted in my installation.
#5
@
4 years ago
- Component changed from General to Plugins
- Milestone Awaiting Review deleted
Hi there, welcome to WordPress Trac! Thanks for the ticket.
Just to clarify, $wp_filter
is declared as a global earlier in wp-includes/plugin.php, so it is always set at this point and an isset()
check would be redundant.
The variable is not set on a first installation of WordPress, so it is triggering a NOTICE debug error.
Although NOTICE errors are suppressed, this code smell should be fixed.
Trac ticket: https://core.trac.wordpress.org/ticket/51728#ticket