Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#26775 closed defect (bug) (fixed)

Fatal error in wp_reset_postdata()

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Priority: normal Milestone: 3.8.1
Component: Query Version: 3.7
Severity: normal Keywords: has-patch needs-unit-tests fixed-major
Cc: Focuses:

Description

[25601] introduced a ​fatal error when calling wp_reset_query() or wp_reset_postdata() without a valid $wp_query global:

Fatal error: Call to a member function reset_postdata() on a non-object in wp-includes/query.php on line 118

We should probably add a _doing_it_wrong() message in there, but at least let's fix the fatal error.

Attachments (1)

26775.patch​ (384 bytes ) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
13 years ago

26775.patch​ uses a basic isset() check, like the ones we already have for template tags:
tags/3.8/src/wp-includes/query.php#L139​

#2 @nacin
13 years ago

  • Milestone 3.9 → 3.8.1

#3 @nacin
13 years ago

This looks good.

#4 @SergeyBiryukov
13 years ago

  • Keywords fixed-major added
  • Owner set to SergeyBiryukov
  • Status new → accepted

Fixed for trunk in [26932].

#5 @nacin
13 years ago

  • Resolution → fixed
  • Status accepted → closed

In 26951:

Avoid a fatal error in wp_reset_postdata() if $wp_query global is not set.

Merges [25932] to the 3.9 branch.

props SergeyBiryukov.
fixes #26775.

#6 @kovshenin
13 years ago

In [26951] Nacin meant the 3.8 branch, not 3.9.

#7 @nacin
13 years ago

Indeed.

Note: See TracTickets for help on using tickets.