Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51728 closed defect (bug) (invalid)

Fix uninitialized variable wp_filter

Reported by: mikaelmayer's profile 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

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

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:

Please remember that the WordPress project is largely maintained by volunteers

Thank you,
The WordPress Project

#3 @mikaelmayer
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

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 @SergeyBiryukov
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.

#6 @mikaelmayer
4 years ago

Oh I see, that was not on the same level. You're right. I'm testing a new VM for PHP and it looks like it was not taking these global definitions into account.

Note: See TracTickets for help on using tickets.