WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#17118 closed defect (bug) (fixed)

[17552] can generate notices for meta_query

Reported by: nacin Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords: has-patch
Focuses: Cc:

Description

Just published a new post, and saw:

Notice: Undefined index: meta_query in /Users/nacin/Sites/beta/wp-includes/query.php on line 2469
Notice: Undefined index: meta_query in /Users/nacin/Sites/beta/wp-includes/query.php on line 2470

Setting to 3.1.2 for now as I haven't yet evaluated if these notices are indicative of an actual bug being triggered.

Attachments (3)

17118.diff (324 bytes) - added by greuben 5 years ago.
17118.2.diff (505 bytes) - added by greuben 5 years ago.
or check if meta_query is set..
17118.3.diff (885 bytes) - added by dd32 5 years ago.

Download all attachments as: .zip

Change History (17)

#1 @greuben
5 years ago

The only possible reason I think of is unsetting meta_query using pre_get_posts filter... if that is the case then adding meta_query in WP_Query::fill_query_vars() will solve it.

#2 @nacin
5 years ago

I was doing a wp_query->set() on pre_get_posts, but avoided meta query. It triggered query_vars_changed but meta query wasn't set for some reason.

#3 @greuben
5 years ago

Debugged a little bit further... its happens when directly calling $wp_query->query(); which is used in wp_get_post_autosave(). Adding meta_query in $wp_query->fill_query_vars() solves it..

@greuben
5 years ago

@greuben
5 years ago

or check if meta_query is set..

#4 @scribu
5 years ago

  • Keywords has-patch added

17118.diff looks like the way to go.

#5 @greuben
5 years ago

I think this can be closed as "Fixed" if #17165 is committed.

#6 in reply to: ↑ description @greuben
5 years ago

  • Keywords fixed-major added

Replying to nacin:

Setting to 3.1.2 for now as I haven't yet evaluated if these notices are indicative of an actual bug being triggered.

Is this for 3.1.2 or 3.2??

#7 @nacin
5 years ago

Either of these patches should go in, if running this block of code with meta_query not set produces side effects. It doesn't look like it does anything though if that's the case.

#8 @greuben
5 years ago

  • Keywords fixed-major removed

#9 follow-up: @dd32
5 years ago

I think this can be closed as "Fixed" if #17165 is committed.

[17699] (the main commit in the above ticket) removed the code in question here. I cant duplicate it in 3.1, I've tried various pre_get_post filters too.. I remember coming across this exact issue a different way (and thought it was fixed before 3.1 was released)

#10 in reply to: ↑ 9 @greuben
5 years ago

Replying to dd32:

I think this can be closed as "Fixed" if #17165 is committed.

I cant duplicate it in 3.1,

To reproduce this issue in 3.1.1, alter the query vars using pre_get_posts filter then edit a post which has autosaves.

I've tried various pre_get_post filters too.. I remember coming across this exact issue a different way (and thought it was fixed before 3.1 was released)

IIRC, before 3.1 there was no meta_query.

#11 @dd32
5 years ago

To reproduce this issue in 3.1.1, alter the query vars using pre_get_posts filter then edit a post which has autosaves.

Cheers, I'll give that one a shot, Chances are, what I saw was the same problem, caused by a different code-path.

IIRC, before 3.1 there was no meta_query.

3.1-bleeding was where I saw it :)

#12 @dd32
5 years ago

  • Component changed from General to Query
  • Milestone changed from 3.2 to 3.1.3
  • Version set to 3.1

I cant duplicate it in 3.1

Was a PEBKAC issue :)

Both of these patches prevent meta_key & meta_value from being set on filters such as pre_get_posts.

However, This is no longer an issue in trunk, and historically we've not patched Notice's in point releaes..

Attaching a patch which would fix it for 3.1.x and assigning to 3.1.3

@dd32
5 years ago

#13 @dd32
5 years ago

Both of these patches prevent meta_key & meta_value from being set on filters such as pre_get_posts.

And I was wrong, Greuben's 17118.diff patch does indeed allow it to work, leading to the patch i uploaded being overkill. Short of a plugin unsetting meta_query on the posts_search filter, there's nothing that would cause it to not work.

#14 @ryan
5 years ago

  • Milestone changed from 3.1.3 to 3.2
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.