Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#28009 closed defect (bug) (fixed)

Recent Posts widget breaks ob stack

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

Description

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 {
	ob_flush();
}

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 12 years ago.

Download all attachments as: .zip

Change History (7)

#1 follow-up: @ocean90
12 years ago

  • Milestone Awaiting Review3.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.

@ocean90
12 years ago

#2 @ocean90
12 years ago

  • Keywords has-patch commit added
  • Owner set to ocean90
  • Status newassigned

Introduced in [27966].

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

Replying to ocean90:

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

+1

#4 @ocean90
12 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
12 years ago

  • Keywords fixed-major added

#6 @nacin
12 years ago

  • Resolutionfixed
  • Status assignedclosed

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.