Index: src/wp-includes/plugin.php
===================================================================
--- src/wp-includes/plugin.php	(revision 36951)
+++ src/wp-includes/plugin.php	(working copy)
@@ -209,13 +209,15 @@
 	}
 
 	if ( !isset($wp_filter[$tag]) ) {
-		if ( isset($wp_filter['all']) )
+		if ( isset($wp_filter['all']) ) {
 			array_pop($wp_current_filter);
+		}
 		return $value;
 	}
 
-	if ( !isset($wp_filter['all']) )
+	if ( !isset($wp_filter['all']) ) {
 		$wp_current_filter[] = $tag;
+	}
 
 	// Sort.
 	if ( !isset( $merged_filters[ $tag ] ) ) {
@@ -223,20 +225,19 @@
 		$merged_filters[ $tag ] = true;
 	}
 
-	reset( $wp_filter[ $tag ] );
-
-	if ( empty($args) )
+	if ( empty($args) ) {
 		$args = func_get_args();
+	}
 
-	do {
-		foreach ( (array) current($wp_filter[$tag]) as $the_ )
+	foreach ( $wp_filter[ $tag ] as $hooks ) {
+		foreach ( (array) $hooks as $the_ ) {
 			if ( !is_null($the_['function']) ){
 				$args[1] = $value;
 				$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
 			}
+		}
+	}
 
-	} while ( next($wp_filter[$tag]) !== false );
-
 	array_pop( $wp_current_filter );
 
 	return $value;
@@ -269,13 +270,15 @@
 	}
 
 	if ( !isset($wp_filter[$tag]) ) {
-		if ( isset($wp_filter['all']) )
+		if ( isset($wp_filter['all']) ) {
 			array_pop($wp_current_filter);
+		}
 		return $args[0];
 	}
 
-	if ( !isset($wp_filter['all']) )
+	if ( !isset($wp_filter['all']) ) {
 		$wp_current_filter[] = $tag;
+	}
 
 	// Sort
 	if ( !isset( $merged_filters[ $tag ] ) ) {
@@ -283,15 +286,14 @@
 		$merged_filters[ $tag ] = true;
 	}
 
-	reset( $wp_filter[ $tag ] );
-
-	do {
-		foreach ( (array) current($wp_filter[$tag]) as $the_ )
-			if ( !is_null($the_['function']) )
+	foreach ( $wp_filter[ $tag ] as $hooks ) {
+		foreach ( (array) $hooks as $the_ ) {
+			if ( !is_null($the_['function']) ){
 				$args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+			}
+		}
+	}
 
-	} while ( next($wp_filter[$tag]) !== false );
-
 	array_pop( $wp_current_filter );
 
 	return $args[0];
@@ -482,10 +484,11 @@
 function do_action($tag, $arg = '') {
 	global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
 
-	if ( ! isset($wp_actions[$tag]) )
+	if ( ! isset($wp_actions[$tag]) ) {
 		$wp_actions[$tag] = 1;
-	else
+	} else {
 		++$wp_actions[$tag];
+	}
 
 	// Do 'all' actions first
 	if ( isset($wp_filter['all']) ) {
@@ -495,21 +498,26 @@
 	}
 
 	if ( !isset($wp_filter[$tag]) ) {
-		if ( isset($wp_filter['all']) )
+		if ( isset($wp_filter['all']) ) {
 			array_pop($wp_current_filter);
+		}
 		return;
 	}
 
-	if ( !isset($wp_filter['all']) )
+	if ( !isset($wp_filter['all']) ) {
 		$wp_current_filter[] = $tag;
+	}
 
 	$args = array();
-	if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
+	if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) { // array(&$this)
 		$args[] =& $arg[0];
-	else
+	} else {
 		$args[] = $arg;
-	for ( $a = 2, $num = func_num_args(); $a < $num; $a++ )
+	}
+
+	for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) {
 		$args[] = func_get_arg($a);
+	}
 
 	// Sort
 	if ( !isset( $merged_filters[ $tag ] ) ) {
@@ -517,15 +525,14 @@
 		$merged_filters[ $tag ] = true;
 	}
 
-	reset( $wp_filter[ $tag ] );
-
-	do {
-		foreach ( (array) current($wp_filter[$tag]) as $the_ )
-			if ( !is_null($the_['function']) )
+	foreach ( $wp_filter[$tag] as $hooks ) {
+		foreach ( (array) $hooks as $the_ ) {
+			if ( !is_null($the_['function']) ) {
 				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+			}
+		}
+	}
 
-	} while ( next($wp_filter[$tag]) !== false );
-
 	array_pop($wp_current_filter);
 }
 
@@ -566,10 +573,11 @@
 function do_action_ref_array($tag, $args) {
 	global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
 
-	if ( ! isset($wp_actions[$tag]) )
+	if ( ! isset($wp_actions[$tag]) ) {
 		$wp_actions[$tag] = 1;
-	else
+	} else {
 		++$wp_actions[$tag];
+	}
 
 	// Do 'all' actions first
 	if ( isset($wp_filter['all']) ) {
@@ -579,13 +587,15 @@
 	}
 
 	if ( !isset($wp_filter[$tag]) ) {
-		if ( isset($wp_filter['all']) )
+		if ( isset($wp_filter['all']) ) {
 			array_pop($wp_current_filter);
+		}
 		return;
 	}
 
-	if ( !isset($wp_filter['all']) )
+	if ( !isset($wp_filter['all']) ) {
 		$wp_current_filter[] = $tag;
+	}
 
 	// Sort
 	if ( !isset( $merged_filters[ $tag ] ) ) {
@@ -593,15 +603,14 @@
 		$merged_filters[ $tag ] = true;
 	}
 
-	reset( $wp_filter[ $tag ] );
-
-	do {
-		foreach ( (array) current($wp_filter[$tag]) as $the_ )
-			if ( !is_null($the_['function']) )
+	foreach ( $wp_filter[$tag] as $hooks ) {
+		foreach ( (array) $hooks as $the_ ) {
+			if ( !is_null($the_['function']) ) {
 				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+			}
+		}
+	}
 
-	} while ( next($wp_filter[$tag]) !== false );
-
 	array_pop($wp_current_filter);
 }
 
