[wp-trac] [WordPress Trac] #33449: WP_User_Query generating notice (undefined index has_published_posts)

WordPress Trac noreply at wordpress.org
Thu Aug 20 01:25:34 UTC 2015


#33449: WP_User_Query generating notice (undefined index has_published_posts)
-------------------------------------------+------------------
 Reporter:  Veraxus                        |       Owner:
     Type:  defect (bug)                   |      Status:  new
 Priority:  normal                         |   Milestone:  4.4
Component:  Query                          |     Version:  4.3
 Severity:  normal                         |  Resolution:
 Keywords:  needs-patch reporter-feedback  |     Focuses:
-------------------------------------------+------------------
Changes (by boonebgorges):

 * keywords:  has-patch => needs-patch reporter-feedback
 * milestone:  Awaiting Review => 4.4


Comment:

 I think this is probably happening because a plugin (or something) is
 overriding query vars in a funny way. Here are two different ways to cause
 notices like the ones reported here:

 {{{
 $q = new WP_User_Query();
 $q->query_vars = array( 'foo' => 'bar' );
 $q->prepare_query();
 }}}

 {{{
 add_action( 'pre_get_users', function( $q ) {
     $q->query_vars = array( 'foo' => 'bar' );
 } );

 $args = array( ... );
 $q = new WP_User_Query( $args );
 }}}

 In both cases, `query_vars` is being manipulated manually. If you pass a
 dumb array like `array( 'foo' => 'bar' )` you will see a ton of notices.
 My guess is that a plugin is passing a relatively comprehensive of query
 vars, but it hasn't been updated to include 'has_published_posts', so
 you're only seeing a notice for that one.

 As dd32 hints, we should probably be running `wp_parse_args()` in all
 cases, and possibly after the 'pre_get_users' filter, to make sure all
 values are set. (See `WP_Query::fill_query_vars()` and `'pre_get_posts'`.)

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


More information about the wp-trac mailing list