[wp-trac] [WordPress Trac] #48524: Notice: Undefined variable: matches

WordPress Trac noreply at wordpress.org
Sat Nov 9 11:24:17 UTC 2019


#48524: Notice: Undefined variable: matches
-------------------------------+------------------------------
 Reporter:  kevinmrlw          |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Query              |     Version:  3.3
 Severity:  minor              |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by SergeyBiryukov):

 * version:  5.2.4 => 3.3


Comment:

 [source:tags/5.2.4/src/wp-includes/class-wp.php?marks=246,251#L245 Looking
 at WP::parse_request()], this notice is only displayed if
 `$this->matched_rule` is set and `$matches` is not.

 In the [source:tags/5.2.4/src/wp-includes/class-wp.php?marks=246,251#L206
 conditional branches above], they are both set simultaneously, so it looks
 like this can only be reproduced by manually setting `$wp->matched_rule`
 on `init` or `wp_loaded` action and visiting the site home page:

 {{{
 function wp48524_set_matched_rule() {
         $GLOBALS['wp']->matched_rule = 'test';
 }
 add_action( 'init', 'wp48524_set_matched_rule' );
 }}}

 The code in question was added in [18466] for #17177. While we could add a
 check to avoid the notice, I'm still curious which plugin or code causes
 it, and what is the use case there.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48524#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list