Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#977 closed defect (bug) (wontfix)

the loop should clean up after itself

Reported by: coffee2code Owned by: skippy
Milestone: Priority: normal
Severity: minor Version: 1.5
Component: Administration Keywords: bg|squashed
Focuses: Cc:


The loop, by calling the_post(), sets up various global variables with values relevant to each post as it iterates through posts. However, when the loop is done, the global variables are left with the values set from the last iteration.

Other than being cleaner, this has relevance to the followup bug report I'll submit, a feature request which should soon be listed as having a dependent relationship to this bug.

Attachments (1)

bug977-end_the_post.diff (1.6 KB) - added by coffee2code 13 years ago.

Download all attachments as: .zip

Change History (7)

#1 @coffee2code
13 years ago

  • Patch set to No

#2 @coffee2code
13 years ago

  • Patch changed from No to Yes

#3 @chrisgalfi
13 years ago

I'm experiencing problems with calling the loop twice and running into similar problems with things not getting cleaned up. I would like to add, that globals should not be used inside the WP query object, rather, passed into the functions or returned. This would make the WP query object reusable. Unsetting global variables will just prolong the true problem.

I haven't gone far enough to recommend a solution just yet, but I will unless someone else has an idea. If you want to contact me directly, I'm available at: chrisgalfi(at)gmail.com.

#4 @Denis de Bernardy
13 years ago

Would it make more sense to isolate the WP query entirely? That would enable a you to create and use several loops at once, in very much the same way as you would create several datasets in an asp.NET application.

#5 @skippy
13 years ago

  • Keywords bg|has-patch added
  • Owner changed from anonymous to skippy
  • Status changed from new to assigned

#6 @markjaquith
13 years ago

  • Keywords bg|squashed added; bg|has-patch removed
  • Resolution set to wontfix
  • Status changed from assigned to closed

This was discussed, and we decided that some things depend on those vars remaining fixed, so we don't want to break any compatibility.

Note: See TracTickets for help on using tickets.