Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28009 closed defect (bug) (fixed)

Recent Posts widget breaks ob stack

Reported by: m_i_n's profile m_i_n Owned by: ocean90's profile ocean90
Milestone: 3.9.1 Priority: normal
Severity: normal Version: 3.9
Component: Widgets Keywords: has-patch commit fixed-major
Focuses: administration Cc:


Please have a look at the following part of "Recent Posts" widget code (default-widgets.php, from line 731):

if ( ! $this->is_preview() ) {
	$cache[ $args['widget_id'] ] = ob_get_flush();
	wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
} else {

If you're not in is_preview(), output buffer is returned to var, flushed, and turns output buffering off (it's OK). However, in other case, buffer in not returned to var, flushed (it's OK until now), but output buffering is not turned off (it should be ob_end_flush instead of ob_flush). It breaks ob stack.

The bug is noticeable in Appearance / Customize, if a theme uses output buffering on the dynamic_sidebar() function, and the widget is active.

Attachments (1)

28009.patch (414 bytes) - added by ocean90 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 follow-up: @ocean90
10 years ago

  • Milestone changed from Awaiting Review to 3.9.1

Hello m_i_n, thanks for the report.

From the PHP docs:

  • ob_get_flush: Flush the output buffer, return it as a string and turn off output buffering
  • ob_flush: Flush (send) the output buffer
  • ob_end_flush: Flush (send) the output buffer and turn off output buffering

So I agree, we should use ob_end_flush() here.

10 years ago

#2 @ocean90
10 years ago

  • Keywords has-patch commit added
  • Owner set to ocean90
  • Status changed from new to assigned

Introduced in [27966].

#3 in reply to: ↑ 1 @westonruter
10 years ago

Replying to ocean90:

So I agree, we should use ob_end_flush() here.


#4 @ocean90
10 years ago

In 28195:

Recent Posts Widget: Use ob_end_flush() instead of ob_flush().

ob_end_flush() flushes the output buffer *and* turns output buffering off, same as ob_get_flush().

props m_i_n.
see #28009 for trunk.

#5 @ocean90
10 years ago

  • Keywords fixed-major added

#6 @nacin
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 28196:

Recent Posts Widget: Use ob_end_flush() instead of ob_flush().

Merges [28195] to the 3.9 branch.

props m_i_n.
fixes #28009.

Note: See TracTickets for help on using tickets.