Index: wp-rss.php
===================================================================
--- wp-rss.php	(revision 3839)
+++ wp-rss.php	(working copy)
@@ -21,7 +21,7 @@
 	<language><?php echo get_option('rss_language'); ?></language>
 	<?php do_action('rss_head'); ?>
 
-<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
 	<item>
 		<title><?php the_title_rss() ?></title>
 <?php if (get_settings('rss_use_excerpt')) { ?>
Index: wp-includes/class-snoopy.php
===================================================================
--- wp-includes/class-snoopy.php	(revision 3839)
+++ wp-includes/class-snoopy.php	(working copy)
@@ -812,7 +812,7 @@
 			reset($this->cookies);
 			if ( count($this->cookies) > 0 ) {
 				$cookie_headers .= 'Cookie: ';
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+				foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) {
 				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
 				}
 				$headers .= substr($cookie_headers,0,-2) . "\r\n";
@@ -976,7 +976,7 @@
 			reset($this->cookies);
 			if ( count($this->cookies) > 0 ) {
 				$cookie_str = 'Cookie: ';
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+				foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) {
 				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
 				}
 				$headers[] = substr($cookie_str,0,-2);
Index: wp-includes/template-functions-general.php
===================================================================
--- wp-includes/template-functions-general.php	(revision 3839)
+++ wp-includes/template-functions-general.php	(working copy)
@@ -329,7 +329,7 @@
 		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
 		if ( $arcresults ) {
 			$afterafter = $after;
-			foreach ( $arcresults as $arcresult ) {
+			foreach ( (array) $arcresults as $arcresult ) {
 				$url	= get_month_link($arcresult->year,	$arcresult->month);
 				if ( $show_post_count ) {
 					$text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
@@ -343,7 +343,7 @@
 	} elseif ( 'daily' == $type ) {
 		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
 		if ( $arcresults ) {
-			foreach ( $arcresults as $arcresult ) {
+			foreach ( (array) $arcresults as $arcresult ) {
 				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
 				$date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
 				$text = mysql2date($archive_day_date_format, $date);
@@ -355,7 +355,7 @@
 		$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
 		$arc_w_last = '';
 		if ( $arcresults ) {
-				foreach ( $arcresults as $arcresult ) {
+				foreach ( (array) $arcresults as $arcresult ) {
 					if ( $arcresult->week != $arc_w_last ) {
 						$arc_year = $arcresult->yr;
 						$arc_w_last = $arcresult->week;
@@ -372,7 +372,7 @@
 		('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
 		$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit");
 		if ( $arcresults ) {
-			foreach ( $arcresults as $arcresult ) {
+			foreach ( (array) $arcresults as $arcresult ) {
 				if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
 					$url  = get_permalink($arcresult);
 					$arc_title = $arcresult->post_title;
@@ -462,7 +462,7 @@
 		$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
 	}
 
-	foreach ( $myweek as $wd ) {
+	foreach ( (array) $myweek as $wd ) {
 		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
 		echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
 	}
@@ -506,7 +506,7 @@
 		AND post_type = 'post' AND post_status = 'publish'
 		AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
 	if ( $dayswithposts ) {
-		foreach ( $dayswithposts as $daywith ) {
+		foreach ( (array) $dayswithposts as $daywith ) {
 			$daywithpost[] = $daywith[0];
 		}
 	} else {
@@ -529,7 +529,7 @@
 		."AND post_type = 'post' AND post_status = 'publish'"
 	);
 	if ( $ak_post_titles ) {
-		foreach ( $ak_post_titles as $ak_post_title ) {
+		foreach ( (array) $ak_post_titles as $ak_post_title ) {
 				if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
 					$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
 				if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
@@ -577,10 +577,10 @@
 function allowed_tags() {
 	global $allowedtags;
 	$allowed = '';
-	foreach ( $allowedtags as $tag => $attributes ) {
+	foreach ( (array) $allowedtags as $tag => $attributes ) {
 		$allowed .= '<'.$tag;
 		if ( 0 < count($attributes) ) {
-			foreach ( $attributes as $attribute => $limits ) {
+			foreach ( (array) $attributes as $attribute => $limits ) {
 				$allowed .= ' '.$attribute.'=""';
 			}
 		}
Index: wp-includes/template-functions-category.php
===================================================================
--- wp-includes/template-functions-category.php	(revision 3839)
+++ wp-includes/template-functions-category.php	(working copy)
@@ -59,7 +59,7 @@
 	$thelist = '';
 	if ( '' == $separator ) {
 		$thelist .= '<ul class="post-categories">';
-		foreach ( $categories as $category ) {
+		foreach ( (array) $categories as $category ) {
 			$thelist .= "\n\t<li>";
 			switch ( strtolower($parents) ) {
 				case 'multiple':
@@ -81,7 +81,7 @@
 		$thelist .= '</ul>';
 	} else {
 		$i = 0;
-		foreach ( $categories as $category ) {
+		foreach ( (array) $categories as $category ) {
 			if ( 0 < $i )
 				$thelist .= $separator . ' ';
 			switch ( strtolower($parents) ) {
@@ -140,7 +140,7 @@
 		return '';
 
 	$cat_ids = get_all_category_ids();
-	foreach ( $cat_ids as $cat_id ) {
+	foreach ( (array) $cat_ids as $cat_id ) {
 		if ( $cat_id == $id)
 			continue;
 
@@ -266,7 +266,7 @@
 		return array();
 
 	$category_list = array();
-	foreach ( $categories as $category ) {
+	foreach ( (array) $categories as $category ) {
 		if ( $category->category_parent == $category_id ) {
 			$category_list[] = $category;
 			if ( $children = _get_cat_children($category->cat_ID, $categories) )
@@ -298,7 +298,7 @@
 		$exclude = '';  
 		$incategories = preg_split('/[\s,]+/',$include);
 		if ( count($incategories) ) {
-			foreach ( $incategories as $incat ) {
+			foreach ( (array) $incategories as $incat ) {
 				if (empty($inclusions))
 					$inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
 				else
@@ -314,7 +314,7 @@
 	if ( !empty($exclude) ) {
 		$excategories = preg_split('/[\s,]+/',$exclude);
 		if ( count($excategories) ) {
-			foreach ( $excategories as $excat ) {
+			foreach ( (array) $excategories as $excat ) {
 				if (empty($exclusions))
 					$exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
 				else
@@ -346,7 +346,7 @@
 		$stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
 							WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
 		global $cat_stamps;
-		foreach ($stamps as $stamp)
+		foreach ( (array) $stamps as $stamp)
 			$cat_stamps[$stamp->category_id] = $stamp->ts;
 		function stamp_cat($cat) {
 			global $cat_stamps;
Index: wp-includes/locale.php
===================================================================
--- wp-includes/locale.php	(revision 3839)
+++ wp-includes/locale.php	(working copy)
@@ -32,7 +32,7 @@
 		$this->weekday_initial[__('Friday')]    = __('F_Friday_initial');
 		$this->weekday_initial[__('Saturday')]  = __('S_Saturday_initial');
 
-		foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
+		foreach ( (array) $this->weekday_initial as $weekday_ => $weekday_initial_) {
 			$this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
 		}
 
@@ -74,7 +74,7 @@
 		$this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
 		$this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
 
-		foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
+		foreach ( (array) $this->month_abbrev as $month_ => $month_abbrev_) {
 			$this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
 		}
 
Index: wp-includes/cache.php
===================================================================
--- wp-includes/cache.php	(revision 3839)
+++ wp-includes/cache.php	(working copy)
@@ -188,7 +188,7 @@
 		if ('category' == $group) {
 			$this->cache['category'] = array ();
 			if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
-				foreach ($dogs as $catt)
+				foreach ( (array) $dogs as $catt)
 					$this->cache['category'][$catt->cat_ID] = $catt;
 			}
 		} else
@@ -202,7 +202,7 @@
 				if ( ! $options )
 					return;
 
-				foreach ($options as $option) {
+				foreach ( (array) $options as $option) {
 					$this->cache['options'][$option->option_name] = $option->option_value;
 				}
 			}
@@ -258,7 +258,7 @@
 		}
 
 		$stack = array_reverse($stack);  // Last added dirs are deepest
-		foreach($stack as $dir) {
+		foreach( (array) $stack as $dir) {
 			if ( $dir != $top_dir)
 				@ rmdir($dir);
 		}
@@ -326,11 +326,11 @@
 
 		// Loop over dirty objects and save them.
 		$errors = 0;
-		foreach ($this->dirty_objects as $group => $ids) {
+		foreach ( (array) $this->dirty_objects as $group => $ids) {
 			$group_dir = $this->make_group_dir($group, $dir_perms);
 
 			$ids = array_unique($ids);
-			foreach ($ids as $id) {
+			foreach ( (array) $ids as $id) {
 				$cache_file = $group_dir.$this->hash($id).'.php';
 
 				// Remove the cache file if the key is not set.
@@ -376,7 +376,7 @@
 		echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
 		echo "</p>";
 
-		foreach ($this->cache as $group => $cache) {
+		foreach ( (array) $this->cache as $group => $cache) {
 			echo "<p>";
 			echo "<strong>Group:</strong> $group<br/>";
 			echo "<strong>Cache:</strong>";
Index: wp-includes/template-functions-post.php
===================================================================
--- wp-includes/template-functions-post.php	(revision 3839)
+++ wp-includes/template-functions-post.php	(working copy)
@@ -207,7 +207,7 @@
 	if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta	WHERE post_id = '$post_id' ORDER BY post_id, meta_key", ARRAY_A) ) {
 		// Change from flat structure to hierarchical:
 		$post_meta_cache = array();
-		foreach ( $meta_list as $metarow ) {
+		foreach ( (array) $meta_list as $metarow ) {
 			$mpid = $metarow['post_id'];
 			$mkey = $metarow['meta_key'];
 			$mval = $metarow['meta_value'];
@@ -261,7 +261,7 @@
 
 	if ( $keys = get_post_custom_keys() ) {
 		echo "<ul class='post-meta'>\n";
-		foreach ( $keys as $key ) {
+		foreach ( (array) $keys as $key ) {
 			$keyt = trim($key);
 			if ( '_' == $keyt{0} )
 				continue;
@@ -297,7 +297,7 @@
 		$pages = &$page_cache;
 
 	$page_list = array();
-	foreach ( $pages as $page ) {
+	foreach ( (array) $pages as $page ) {
 		if ( $page->post_parent == $page_id ) {
 			$page_list[] = $page;
 			if ( $children = get_page_children($page->ID, $pages) )
@@ -329,7 +329,7 @@
 		$meta_value = '';
 		$incpages = preg_split('/[\s,]+/',$include);
 		if ( count($incpages) ) {
-			foreach ( $incpages as $incpage ) {
+			foreach ( (array) $incpages as $incpage ) {
 				if (empty($inclusions))
 					$inclusions = ' AND ( ID = ' . intval($incpage) . ' ';
 				else
@@ -344,7 +344,7 @@
 	if ( !empty($exclude) ) {
 		$expages = preg_split('/[\s,]+/',$exclude);
 		if ( count($expages) ) {
-			foreach ( $expages as $expage ) {
+			foreach ( (array) $expages as $expage ) {
 				if (empty($exclusions))
 					$exclusions = ' AND ( ID <> ' . intval($expage) . ' ';
 				else
@@ -497,8 +497,8 @@
 
 		$types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime));
 		$exts = array('jpg', 'gif', 'png');
-		foreach ($types as $type) {
-			foreach ($exts as $ext) {
+		foreach ( (array) $types as $type) {
+			foreach ( (array) $exts as $ext) {
 				$src_file = "$icon_dir/$type.$ext";
 				if ( file_exists($src_file) ) {
 					$src = "$icon_dir_uri/$type.$ext";
Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 3839)
+++ wp-includes/query.php	(working copy)
@@ -709,7 +709,7 @@
 			$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
 			$cat_array = preg_split('/[,\s]+/', $q['cat']);
 			$in_cats = $out_cats = '';
-			foreach ( $cat_array as $cat ) {
+			foreach ( (array) $cat_array as $cat ) {
 				$cat = intval($cat);
 				$in = strstr($cat, '-') ? false : true;
 				$cat = trim($cat, '-');
@@ -740,7 +740,7 @@
 			$cat_paths = '/' . trim(urldecode($q['category_name']), '/');
 			$q['category_name'] = sanitize_title(basename($cat_paths));
 			$cat_paths = explode('/', $cat_paths);
-			foreach($cat_paths as $pathdir)
+			foreach( (array) $cat_paths as $pathdir)
 				$cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
 
 			//if we don't match the entire hierarchy fallback on just matching the nicename
Index: wp-includes/template-functions-bookmarks.php
===================================================================
--- wp-includes/template-functions-bookmarks.php	(revision 3839)
+++ wp-includes/template-functions-bookmarks.php	(working copy)
@@ -91,7 +91,7 @@
 
 	$output = '';
 
-	foreach ($results as $row) {
+	foreach ( (array) $results as $row) {
 		if (!isset($row->recently_updated)) $row->recently_updated = false;
 			$output .= $before;
 		if ($show_updated && $row->recently_updated) {
@@ -244,7 +244,7 @@
 
 	// Display each category
 	if ($cats) {
-		foreach ($cats as $cat) {
+		foreach ( (array) $cats as $cat) {
 			// Handle each category.
 
 			// Display the category name
@@ -300,7 +300,7 @@
 	$category_name = '';
 		$inclinks = preg_split('/[\s,]+/',$include);
 		if ( count($inclinks) ) {
-			foreach ( $inclinks as $inclink ) {
+			foreach ( (array) $inclinks as $inclink ) {
 				if (empty($inclusions))
 					$inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
 				else
@@ -315,7 +315,7 @@
 	if ( !empty($exclude) ) {
 		$exlinks = preg_split('/[\s,]+/',$exclude);
 		if ( count($exlinks) ) {
-			foreach ( $exlinks as $exlink ) {
+			foreach ( (array) $exlinks as $exlink ) {
 				if (empty($exclusions))
 					$exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
 				else
@@ -336,7 +336,7 @@
 	if ( !empty($category) ) {
 		$incategories = preg_split('/[\s,]+/',$category);
 		if ( count($incategories) ) {
-			foreach ( $incategories as $incat ) {
+			foreach ( (array) $incategories as $incat ) {
 				if (empty($category_query))
 					$category_query = ' AND ( category_id = ' . intval($incat) . ' ';
 				else
Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 3839)
+++ wp-includes/wp-db.php	(working copy)
@@ -253,7 +253,7 @@
 		} elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
 			if ( $this->last_result ) {
 				$i = 0;
-				foreach( $this->last_result as $row ) {
+				foreach( (array) $this->last_result as $row ) {
 					$new_array[$i] = (array) $row;
 					if ( $output == ARRAY_N ) {
 						$new_array[$i] = array_values($new_array[$i]);
@@ -276,7 +276,7 @@
 		if ( $this->col_info ) {
 			if ( $col_offset == -1 ) {
 				$i = 0;
-				foreach($this->col_info as $col ) {
+				foreach( (array) $this->col_info as $col ) {
 					$new_array[$i] = $col->{$info_type};
 					$i++;
 				}
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 3839)
+++ wp-includes/rewrite.php	(working copy)
@@ -119,7 +119,7 @@
 
 	// Look for matches.
 	$request_match = $request;
-	foreach ($rewrite as $match => $query) {
+	foreach ( (array) $rewrite as $match => $query) {
 		// If the requesting file is the anchor of the match, prepend it
 		// to the path info.
 		if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
@@ -265,13 +265,13 @@
 		$rewrite_rules = array();
 		$page_structure = $this->get_page_permastruct();
 		if( is_array( $attachment_uris ) ) {
-			foreach ($attachment_uris as $uri => $pagename) {
+			foreach ( (array) $attachment_uris as $uri => $pagename) {
 				$this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
 				$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
 			}
 		}
 		if( is_array( $uris ) ) {
-			foreach ($uris as $uri => $pagename) {
+			foreach ( (array) $uris as $uri => $pagename) {
 				$this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
 				$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
 			}
@@ -296,7 +296,7 @@
 		$this->date_structure = '';
 		$date_endian = '';
 
-		foreach ($endians as $endian) {
+		foreach ( (array) $endians as $endian) {
 			if (false !== strpos($this->permalink_structure, $endian)) {
 				$date_endian= $endian;
 				break;
@@ -311,7 +311,7 @@
 		$front = $this->front;
 		preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
 		$tok_index = 1;
-		foreach ($tokens[0] as $token) {
+		foreach ( (array) $tokens[0] as $token) {
 			if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
 				$front = $front . 'date/';
 				break;
@@ -470,7 +470,7 @@
 	function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
 		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
 		$feedregex2 = '';
-		foreach ($this->feeds as $feed_name) {
+		foreach ( (array) $this->feeds as $feed_name) {
 			$feedregex2 .= $feed_name . '|';
 		}
 		$feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
@@ -485,7 +485,7 @@
 		//build up an array of endpoint regexes to append => queries to append
 		if ($endpoints) {
 			$ep_query_append = array ();
-			foreach ($this->endpoints as $endpoint) { 
+			foreach ( (array) $this->endpoints as $endpoint) { 
 				//match everything after the endpoint name, but allow for nothing to appear there
 				$epmatch = $endpoint[1] . '(/(.*))?/?$';
 				//this will be appended on to the rest of the query for each dir
@@ -599,7 +599,7 @@
 				
 				//do endpoints
 				if ($endpoints) {
-					foreach ($ep_query_append as $regex => $ep) {
+					foreach ( (array) $ep_query_append as $regex => $ep) {
 						//add the endpoints on if the mask fits
 						if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
 							$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
@@ -639,7 +639,7 @@
 					$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
 					
 					//do endpoints for attachments
-					if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
+					if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) {
 						if ($ep[0] & EP_ATTACHMENT) {
 							$rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
 							$rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
@@ -677,7 +677,7 @@
 			} //if($num_toks)
 			//add the rules for this dir to the accumulating $post_rewrite
 			$post_rewrite = array_merge($rewrite, $post_rewrite);
-		} //foreach ($dir)
+		} //foreach ( (array) $dir)
 		return $post_rewrite; //the finished rules. phew!
 	}
 
@@ -768,7 +768,7 @@
 		$rules .= "RewriteBase $home_root\n";
 		
 		//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
-		foreach ($this->non_wp_rules as $match => $query) {
+		foreach ( (array) $this->non_wp_rules as $match => $query) {
 			// Apache 1.3 does not support the reluctant (non-greedy) modifier.
 			$match = str_replace('.+?', '.+', $match);
 
@@ -789,7 +789,7 @@
 				"RewriteCond %{REQUEST_FILENAME} -d\n" .
 				"RewriteRule ^.*$ - [S=$num_rules]\n";
 
-			foreach ($rewrite as $match => $query) {
+			foreach ( (array) $rewrite as $match => $query) {
 				// Apache 1.3 does not support the reluctant (non-greedy) modifier.
 				$match = str_replace('.+?', '.+', $match);
 
Index: wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php
===================================================================
--- wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php	(revision 3839)
+++ wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php	(working copy)
@@ -34,7 +34,7 @@
 	function checkWords($wordArray) {
 		if ($fh = fopen($this->tmpfile, "w")) {
 			fwrite($fh, "!\n");
-			foreach($wordArray as $key => $value)
+			foreach( (array) $wordArray as $key => $value)
 				fwrite($fh, "^" . $value . "\n");
 
 			fclose($fh);
@@ -47,7 +47,7 @@
 		$returnData = array();
 		$dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
 
-		foreach($dataArr as $dstr) {
+		foreach( (array) $dataArr as $dstr) {
 			$matches = array();
 
 			// Skip this line.
@@ -76,7 +76,7 @@
 		$returnData = array();
 		$dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
 
-		foreach($dataArr as $dstr) {
+		foreach( (array) $dataArr as $dstr) {
 			$matches = array();
 
 			// Skip this line.
Index: wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php
===================================================================
--- wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php	(revision 3839)
+++ wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php	(working copy)
@@ -61,9 +61,9 @@
         $querystring = '';
         if (is_array($data)) {
             // Change data in to postable data
-    		foreach ($data as $key => $val) {
+    		foreach ( (array) $data as $key => $val) {
     			if (is_array($val)) {
-    				foreach ($val as $val2) {
+    				foreach ( (array) $val as $val2) {
     					$querystring .= urlencode($key).'='.urlencode($val2).'&';
     				}
     			} else {
@@ -165,7 +165,7 @@
             if (!is_array($cookies)) {
                 $cookies = array($cookies);
             }
-            foreach ($cookies as $cookie) {
+            foreach ( (array) $cookies as $cookie) {
                 if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
                     $this->cookies[$m[1]] = $m[2];
                 }
@@ -212,7 +212,7 @@
     	// Cookies
     	if ($this->cookies) {
     	    $cookie = 'Cookie: ';
-    	    foreach ($this->cookies as $key => $value) {
+    	    foreach ( (array) $this->cookies as $key => $value) {
     	        $cookie .= "$key=$value; ";
     	    }
     	    $headers[] = $cookie;
Index: wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php
===================================================================
--- wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php	(revision 3839)
+++ wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php	(working copy)
@@ -39,7 +39,7 @@
 		}
 
 		$wordError = array();
-		foreach($wordArray as $word) {
+		foreach( (array) $wordArray as $word) {
 			if(!pspell_check($this->plink, trim($word)))
 				$wordError[] = $word;
 		}
Index: wp-includes/js/tinymce/tiny_mce_gzip.php
===================================================================
--- wp-includes/js/tinymce/tiny_mce_gzip.php	(revision 3839)
+++ wp-includes/js/tinymce/tiny_mce_gzip.php	(working copy)
@@ -169,7 +169,7 @@
 
 	// Load all plugins and their language packs
 	$plugins = explode(",", $plugins);
-	foreach ($plugins as $plugin) {
+	foreach ( (array) $plugins as $plugin) {
 		$pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
 		/* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */
 
Index: wp-includes/functions-compat.php
===================================================================
--- wp-includes/functions-compat.php	(revision 3839)
+++ wp-includes/functions-compat.php	(working copy)
@@ -90,7 +90,7 @@
         $keys     = array_keys($input);
         $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
 
-        foreach ($keys as $key) {
+        foreach ( (array) $keys as $key) {
             $output[$casefunc($key)] = $input[$key];
         }
 
Index: wp-includes/capabilities.php
===================================================================
--- wp-includes/capabilities.php	(revision 3839)
+++ wp-includes/capabilities.php	(working copy)
@@ -22,7 +22,7 @@
 
 		$this->role_objects = array();
 		$this->role_names =  array();
-		foreach ($this->roles as $role => $data) {
+		foreach ( (array) $this->roles as $role => $data) {
 			$this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
 			$this->role_names[$role] = $this->roles[$role]['name'];
 		}
@@ -174,7 +174,7 @@
 
 		//Build $allcaps from role caps, overlay user's $caps
 		$this->allcaps = array();
-		foreach($this->roles as $role) {
+		foreach( (array) $this->roles as $role) {
 			$role = $wp_roles->get_role($role);
 			$this->allcaps = array_merge($this->allcaps, $role->capabilities);
 		}
@@ -197,7 +197,7 @@
 	}
 
 	function set_role($role) {
-		foreach($this->roles as $oldrole)
+		foreach( (array) $this->roles as $oldrole)
 			unset($this->caps[$oldrole]);
 		$this->caps[$role] = true;
 		$this->roles = array($role => true);
@@ -251,7 +251,7 @@
 		$caps = call_user_func_array('map_meta_cap', $args);
 		// Must have ALL requested caps
 		$capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
-		foreach ($caps as $cap) {
+		foreach ( (array) $caps as $cap) {
 			//echo "Checking cap $cap<br/>";
 			if(empty($capabilities[$cap]) || !$capabilities[$cap])
 				return false;
Index: wp-includes/functions-post.php
===================================================================
--- wp-includes/functions-post.php	(revision 3839)
+++ wp-includes/functions-post.php	(working copy)
@@ -528,7 +528,7 @@
 	$delete_cats = array_diff($old_categories,$post_categories);
 
 	if ($delete_cats) {
-		foreach ($delete_cats as $del) {
+		foreach ( (array) $delete_cats as $del) {
 			$wpdb->query("
 				DELETE FROM $wpdb->post2cat 
 				WHERE category_id = $del 
@@ -541,7 +541,7 @@
 	$add_cats = array_diff($post_categories, $old_categories);
 
 	if ($add_cats) {
-		foreach ($add_cats as $new_cat) {
+		foreach ( (array) $add_cats as $new_cat) {
 			$wpdb->query("
 				INSERT INTO $wpdb->post2cat (post_id, category_id) 
 				VALUES ($post_ID, $new_cat)");
@@ -550,7 +550,7 @@
 
 	// Update category counts.
 	$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
-	foreach ( $all_affected_cats as $cat_id ) {
+	foreach ( (array) $all_affected_cats as $cat_id ) {
 		$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
 		$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
 		wp_cache_delete($cat_id, 'category');
@@ -572,7 +572,7 @@
 	if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
 		$categories = wp_get_post_cats('', $post->ID);
 		if( is_array( $categories ) ) {
-			foreach ( $categories as $cat_id ) {
+			foreach ( (array) $categories as $cat_id ) {
 				$wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
 				wp_cache_delete($cat_id, 'category');
 			}
@@ -663,7 +663,7 @@
 		}
 
 		$trackback_urls = explode(',', $tb_list);
-		foreach($trackback_urls as $tb_url) {
+		foreach( (array) $trackback_urls as $tb_url) {
 		    $tb_url = trim($tb_url);
 		    trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
 		}
@@ -676,7 +676,7 @@
 	do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
 
 	if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
-		foreach ($chars[1] as $char) {
+		foreach ( (array) $chars[1] as $char) {
 			// If it's an encoded char in the normal ASCII set, reject
 			if ( 38 == $char )
 				continue; // Unless it's &
@@ -690,7 +690,7 @@
 		return false; // If moderation keys are empty
 	$words = explode("\n", $mod_keys );
 
-	foreach ($words as $word) {
+	foreach ( (array) $words as $word) {
 		$word = trim($word);
 
 		// Skip empty lines
@@ -752,7 +752,7 @@
 	$post_title = apply_filters('the_title', $post->post_title);
 	$post_title = strip_tags($post_title);
 
-	if ($to_ping) : foreach ($to_ping as $tb_ping) :
+	if ($to_ping) : foreach ( (array) $to_ping as $tb_ping) :
 		$tb_ping = trim($tb_ping);
 		if ( !in_array($tb_ping, $pinged) ) {
 			trackback($tb_ping, $post_title, $excerpt, $post_id);
@@ -779,10 +779,10 @@
 	if ( !is_array( $custom_fields ) )
 		return $pung;
 
-	foreach ( $custom_fields as $key => $val ) {
+	foreach ( (array) $custom_fields as $key => $val ) {
 		if ( 'enclosure' != $key || !is_array( $val ) )
 			continue;
-		foreach( $val as $enc ) {
+		foreach( (array) $val as $enc ) {
 			$enclosure = split( "\n", $enc );
 			$pung[] = trim( $enclosure[ 0 ] );
 		}
@@ -815,7 +815,7 @@
 //immediately follow their parents
 function get_page_hierarchy($posts, $parent = 0) {
 	$result = array ( );
-	if ($posts) { foreach ($posts as $post) {
+	if ($posts) { foreach ( (array) $posts as $post) {
 		if ($post->post_parent == $parent) {
 			$result[$post->ID] = $post->post_name;
 			$children = get_page_hierarchy($posts, $post->ID);
@@ -838,13 +838,13 @@
 
 	if ($posts) {
 
-		foreach ($posts as $id => $post) {
+		foreach ( (array) $posts as $id => $post) {
 
 			// URI => page name
 			$uri = get_page_uri($id);
 			$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'");
 			if ( $attachments ) {
-				foreach ( $attachments as $attachment ) {
+				foreach ( (array) $attachments as $attachment ) {
 					$attach_uri = get_page_uri($attachment->ID);
 					$page_attachment_uris[$attach_uri] = $attachment->ID;
 				}
@@ -1030,7 +1030,7 @@
 	// Do Trackbacks
 	$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
 	if ( is_array($trackbacks) ) {
-		foreach ( $trackbacks as $trackback ) {
+		foreach ( (array) $trackbacks as $trackback ) {
 			do_trackbacks($trackback->ID);
 		}
 	}
Index: wp-includes/classes.php
===================================================================
--- wp-includes/classes.php	(revision 3839)
+++ wp-includes/classes.php	(working copy)
@@ -20,7 +20,7 @@
 		$cnt = 0;
 		$id_list = explode( ',', $id_list );
 
-		foreach ( $id_list as $comment ) {
+		foreach ( (array) $id_list as $comment ) {
 			if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
 				$cnt++;
 			}
@@ -33,9 +33,9 @@
 	function find_spam() {
 		$in_queue = 0;
 
-		foreach( $this->comment_list as $comment ) {
+		foreach( (array) $this->comment_list as $comment ) {
 			if( $comment->approved == 1 ) {
-				foreach( $this->spam_words as $word ) {
+				foreach( (array) $this->spam_words as $word ) {
 					$word = trim($word);
 					if ( empty( $word ) )
 						continue;
@@ -149,7 +149,7 @@
 
 			// Look for matches.
 			$request_match = $request;
-			foreach ($rewrite as $match => $query) {
+			foreach ( (array) $rewrite as $match => $query) {
 				// If the requesting file is the anchor of the match, prepend it
 				// to the path info.
 				if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
@@ -279,7 +279,7 @@
 			}
 		}
 
-		foreach ($this->private_query_vars as $wpvar) {
+		foreach ( (array) $this->private_query_vars as $wpvar) {
 			if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) {
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
 				$this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
@@ -292,7 +292,7 @@
 	function register_globals() {
 		global $wp_query;
 		// Extract updated query vars back into global namespace.
-		foreach ($wp_query->query_vars as $key => $value) {
+		foreach ( (array) $wp_query->query_vars as $key => $value) {
 			$GLOBALS[$key] = $value;
 		}
 
@@ -373,7 +373,7 @@
 		// Return all messages if no code specified.
 		if ( empty($code) ) {
 			$all_messages = array();
-			foreach ( $this->errors as $code => $messages )
+			foreach ( (array) $this->errors as $code => $messages )
 				$all_messages = array_merge($all_messages, $messages);
 
 			return $all_messages;
@@ -431,7 +431,7 @@
 	
 		$flat = ($to_depth == -1) ? true : false;
 	
-		foreach ( $elements as $element ) {
+		foreach ( (array) $elements as $element ) {
 			// If flat, start and end the element and skip the level checks.
 			if ( $flat) {
 				// Start the element.
Index: wp-includes/template-functions-links.php
===================================================================
--- wp-includes/template-functions-links.php	(revision 3839)
+++ wp-includes/template-functions-links.php	(working copy)
@@ -264,7 +264,7 @@
 	$sql_exclude_cats = '';
 	if ( !empty($excluded_categories) ) {
 		$blah = explode(' and ', $excluded_categories);
-		foreach ( $blah as $category ) {
+		foreach ( (array) $blah as $category ) {
 			$category = intval($category);
 			$sql_cat_ids = " OR pc.category_ID = '$category'";
 		}
@@ -297,7 +297,7 @@
 	$sql_exclude_cats = '';
 	if ( !empty($excluded_categories) ) {
 		$blah = explode(' and ', $excluded_categories);
-		foreach ( $blah as $category ) {
+		foreach ( (array) $blah as $category ) {
 			$category = intval($category);
 			$sql_cat_ids = " OR pc.category_ID = '$category'";
 		}
Index: wp-includes/deprecated.php
===================================================================
--- wp-includes/deprecated.php	(revision 3839)
+++ wp-includes/deprecated.php	(working copy)
@@ -206,7 +206,7 @@
     $cat_id = -1;
     $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
     if ($results) {
-        foreach ($results as $result) {
+        foreach ( (array) $results as $result) {
             $cat_id = $result->cat_ID;
         }
     }
@@ -246,7 +246,7 @@
  **
  ** Use this like:
  ** $links = get_linkobjectsbyname('fred');
- ** foreach ($links as $link) {
+ ** foreach ( (array) $links as $link) {
  **   echo '<li>'.$link->link_name.'</li>';
  ** }
  **/
@@ -257,7 +257,7 @@
     //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
     // TODO: Fix me.
     if ($results) {
-        foreach ($results as $result) {
+        foreach ( (array) $results as $result) {
             $cat_id = $result->cat_id;
         }
     }
@@ -280,7 +280,7 @@
  ** Use this like:
  ** $links = get_linkobjects(1);
  ** if ($links) {
- **   foreach ($links as $link) {
+ **   foreach ( (array) $links as $link) {
  **     echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
  **   }
  ** }
@@ -326,7 +326,7 @@
 
     $results = $wpdb->get_results($sql);
     if ($results) {
-        foreach ($results as $result) {
+        foreach ( (array) $results as $result) {
             $result->link_url         = $result->link_url;
             $result->link_name        = $result->link_name;
             $result->link_description = $result->link_description;
Index: wp-includes/cron.php
===================================================================
--- wp-includes/cron.php	(revision 3839)
+++ wp-includes/cron.php	(working copy)
@@ -58,7 +58,7 @@
 	$crons = get_option( 'cron' );
 	if ( empty($crons) )
 		return false;
-	foreach ( $crons as $timestamp => $cron )
+	foreach ( (array) $crons as $timestamp => $cron )
 		if ( isset( $cron[$hook] ) )
 			return $timestamp;
 	return false;
@@ -85,9 +85,9 @@
 		return;
 
 	$schedules = wp_get_schedules();
-	foreach ( $crons as $timestamp => $cronhooks ) {
+	foreach ( (array) $crons as $timestamp => $cronhooks ) {
 		if ( $timestamp > time() ) break;
-		foreach ( $cronhooks as $hook => $args ) {
+		foreach ( (array) $cronhooks as $hook => $args ) {
 			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
 				continue;
 			spawn_cron();
Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 3839)
+++ wp-includes/comment.php	(working copy)
@@ -12,7 +12,7 @@
 	if ( !empty($mod_keys) ) {
 		$words = explode("\n", $mod_keys );
 
-		foreach ($words as $word) {
+		foreach ( (array) $words as $word) {
 			$word = trim($word);
 
 			// Skip empty lines
@@ -348,7 +348,7 @@
 	$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
 
 	// Escape data pulled from DB.
-	foreach ($comment as $key => $value)
+	foreach ( (array) $comment as $key => $value)
 		$comment[$key] = $wpdb->escape($value);
 
 	// Merge old and new fields with new fields overwriting old ones.
@@ -418,7 +418,7 @@
 	// http://dummy-weblog.org/post.php
 	// We don't wanna ping first and second types, even if they have a valid <link/>
 
-	foreach($post_links_temp[0] as $link_test) :
+	foreach( (array) $post_links_temp[0] as $link_test) :
 		if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
 				&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
 			$test = parse_url($link_test);
@@ -431,7 +431,7 @@
 
 	do_action('pre_ping',  array(&$post_links, &$pung));
 
-	foreach ($post_links as $pagelinkedto){
+	foreach ( (array) $post_links as $pagelinkedto){
 		debug_fwrite($log, "Processing -- $pagelinkedto\n");
 		$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
 
Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 3839)
+++ wp-includes/theme.php	(working copy)
@@ -120,7 +120,7 @@
 
 	sort($theme_files);
 
-	foreach($theme_files as $theme_file) {
+	foreach( (array) $theme_files as $theme_file) {
 		if ( ! is_readable("$theme_root/$theme_file") ) {
 			$wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
 			continue;
@@ -213,10 +213,10 @@
 	// Resolve theme dependencies.
 	$theme_names = array_keys($themes);
 
-	foreach ($theme_names as $theme_name) {
+	foreach ( (array) $theme_names as $theme_name) {
 		$themes[$theme_name]['Parent Theme'] = '';
 		if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
-			foreach ($theme_names as $parent_theme_name) {
+			foreach ( (array) $theme_names as $parent_theme_name) {
 				if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
 					$themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
 					break;
@@ -247,7 +247,7 @@
 	$current_theme = 'WordPress Default';
 
 	if ( $themes ) {
-		foreach ($theme_names as $theme_name) {
+		foreach ( (array) $theme_names as $theme_name) {
 			if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
 					$themes[$theme_name]['Template'] == $current_template ) {
 				$current_theme = $themes[$theme_name]['Name'];
Index: wp-includes/class-IXR.php
===================================================================
--- wp-includes/class-IXR.php	(revision 3839)
+++ wp-includes/class-IXR.php	(working copy)
@@ -18,7 +18,7 @@
         $this->type = $type;
         if ($type == 'struct') {
             /* Turn all the values in the array in to new IXR_Value objects */
-            foreach ($this->data as $key => $value) {
+            foreach ( (array) $this->data as $key => $value) {
                 $this->data[$key] = new IXR_Value($value);
             }
         }
@@ -78,7 +78,7 @@
                 break;
             case 'array':
                 $return = '<array><data>'."\n";
-                foreach ($this->data as $item) {
+                foreach ( (array) $this->data as $item) {
                     $return .= '  <value>'.$item->getXml()."</value>\n";
                 }
                 $return .= '</data></array>';
@@ -86,7 +86,7 @@
                 break;
             case 'struct':
                 $return = '<struct>'."\n";
-                foreach ($this->data as $name => $value) {
+                foreach ( (array) $this->data as $name => $value) {
 					$name = htmlspecialchars($name);
                     $return .= "  <member><name>$name</name><value>";
                     $return .= $value->getXml()."</value></member>\n";
@@ -104,7 +104,7 @@
     function isStruct($array) {
         /* Nasty function to check if an array is a struct or not */
         $expected = 0;
-        foreach ($array as $key => $value) {
+        foreach ( (array) $array as $key => $value) {
             if ((string)$key != (string)$expected) {
                 return true;
             }
@@ -397,7 +397,7 @@
     function multiCall($methodcalls) {
         // See http://www.xmlrpc.com/discuss/msgReader$1208
         $return = array();
-        foreach ($methodcalls as $call) {
+        foreach ( (array) $methodcalls as $call) {
             $method = $call['methodName'];
             $params = $call['params'];
             if ($method == 'system.multicall') {
@@ -432,7 +432,7 @@
 <params>
 
 EOD;
-        foreach ($this->args as $arg) {
+        foreach ( (array) $this->args as $arg) {
             $this->xml .= '<param><value>';
             $v = new IXR_Value($arg);
             $this->xml .= $v->getXml();
@@ -754,7 +754,7 @@
         // We should be returning an array of types
         $types = $this->signatures[$method];
         $return = array();
-        foreach ($types as $type) {
+        foreach ( (array) $types as $type) {
             switch ($type) {
                 case 'string':
                     $return[] = 'string';
Index: wp-includes/kses.php
===================================================================
--- wp-includes/kses.php	(revision 3839)
+++ wp-includes/kses.php	(working copy)
@@ -154,7 +154,7 @@
 
 	$attr2 = '';
 
-	foreach ($attrarr as $arreach) {
+	foreach ( (array) $attrarr as $arreach) {
 		if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])]))
 			continue; # the attribute is not allowed
 
@@ -169,7 +169,7 @@
 		else {
 			# there are some checks
 			$ok = true;
-			foreach ($current as $currkey => $currval)
+			foreach ( (array) $current as $currkey => $currval)
 				if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) {
 					$ok = false;
 					break;
@@ -404,11 +404,11 @@
 {
 	$outarray = array ();
 
-	foreach ($inarray as $inkey => $inval) {
+	foreach ( (array) $inarray as $inkey => $inval) {
 		$outkey = strtolower($inkey);
 		$outarray[$outkey] = array ();
 
-		foreach ($inval as $inkey2 => $inval2) {
+		foreach ( (array) $inval as $inkey2 => $inval2) {
 			$outkey2 = strtolower($inkey2);
 			$outarray[$outkey][$outkey2] = $inval2;
 		} # foreach $inval
@@ -457,7 +457,7 @@
 	$string2 = strtolower($string2);
 
 	$allowed = false;
-	foreach ($allowed_protocols as $one_protocol)
+	foreach ( (array) $allowed_protocols as $one_protocol)
 		if (strtolower($one_protocol) == $string2) {
 			$allowed = true;
 			break;
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 3839)
+++ wp-includes/functions.php	(working copy)
@@ -254,7 +254,7 @@
 	}
 	$wpdb->show_errors();
 
-	foreach ($options as $option) {
+	foreach ( (array) $options as $option) {
 		// "When trying to design a foolproof system,
 		//  never underestimate the ingenuity of the fools :)" -- Dougal
 		if ( 'siteurl' == $option->option_name )
@@ -383,7 +383,7 @@
 		$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
 AND meta_key = '$key' AND meta_value = '$value'");
 		$cache_key = $post_meta_cache['$post_id'][$key];
-		if ($cache_key) foreach ( $cache_key as $index => $data )
+		if ($cache_key) foreach ( (array) $cache_key as $index => $data )
 			if ( $data == $value )
 				unset($post_meta_cache['$post_id'][$key][$index]);
 	}
@@ -408,7 +408,7 @@
 
 	$values = array();
 	if ( $metalist ) {
-		foreach ($metalist as $metarow) {
+		foreach ( (array) $metalist as $metarow) {
 			$values[] = $metarow[0];
 		}
 	}
@@ -447,14 +447,14 @@
 meta_key = '$key' AND post_id = '$post_id'");
 		$cache_key = $post_meta_cache['$post_id'][$key];
 		if ( !empty($cache_key) )
-			foreach ($cache_key as $index => $data)
+			foreach ( (array) $cache_key as $index => $data)
 				$post_meta_cache['$post_id'][$key][$index] = $original_value;
 	} else {
 		$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
 meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
 		$cache_key = $post_meta_cache['$post_id'][$key];
 		if ( !empty($cache_key) )
-			foreach ($cache_key as $index => $data)
+			foreach ( (array) $cache_key as $index => $data)
 				if ( $data == $original_prev )
 					$post_meta_cache['$post_id'][$key][$index] = $original_value;
 	}
@@ -527,7 +527,7 @@
 	$children = $wpdb->get_results($query);
 
 	if ( $children ) {
-		foreach ( $children as $key => $child ) {
+		foreach ( (array) $children as $key => $child ) {
 			$post_cache[$child->ID] =& $children[$key];
 			$kids[$child->ID] =& $children[$key];
 		}
@@ -538,11 +538,11 @@
 	if ( $output == OBJECT ) {
 		return $kids;
 	} elseif ( $output == ARRAY_A ) {
-		foreach ( $kids as $kid )
+		foreach ( (array) $kids as $kid )
 			$weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
 		return $weeuns;
 	} elseif ( $output == ARRAY_N ) {
-		foreach ( $kids as $kid )
+		foreach ( (array) $kids as $kid )
 			$babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
 		return $babes;
 	} else {
@@ -558,7 +558,7 @@
 	$page_paths = '/' . trim($page_path, '/');
 	$leaf_path  = sanitize_title(basename($page_paths));
 	$page_paths = explode('/', $page_paths);
-	foreach($page_paths as $pathdir)
+	foreach( (array) $page_paths as $pathdir)
 		$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
 
 	$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
@@ -566,7 +566,7 @@
 	if ( empty($pages) ) 
 		return NULL;
 
-	foreach ($pages as $page) {
+	foreach ( (array) $pages as $page) {
 		$path = '/' . $leaf_path;
 		$curpage = $page;
 		while ($curpage->post_parent != 0) {
@@ -634,7 +634,7 @@
 	$category_paths = '/' . trim($category_path, '/');
 	$leaf_path  = sanitize_title(basename($category_paths));
 	$category_paths = explode('/', $category_paths);
-	foreach($category_paths as $pathdir)
+	foreach( (array) $category_paths as $pathdir)
 		$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
 
 	$categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
@@ -642,7 +642,7 @@
 	if ( empty($categories) ) 
 		return NULL;
 
-	foreach ($categories as $category) {
+	foreach ( (array) $categories as $category) {
 		$path = '/' . $leaf_path;
 		$curcategory = $category;
 		while ($curcategory->category_parent != 0) {
@@ -763,7 +763,7 @@
 	$services = trim($services);
 	if ( '' != $services ) {
 		$services = explode("\n", $services);
-		foreach ($services as $service) {
+		foreach ( (array) $services as $service) {
 			weblog_ping($service);
 		}
 	}
@@ -907,7 +907,7 @@
 	debug_fwrite($log, 'Post contents:');
 	debug_fwrite($log, $content."\n");
 
-	foreach($post_links_temp[0] as $link_test) :
+	foreach( (array) $post_links_temp[0] as $link_test) :
 		if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
 			$test = parse_url($link_test);
 			if ( isset($test['query']) )
@@ -917,7 +917,7 @@
 		endif;
 	endforeach;
 
-	foreach ($post_links as $url) :
+	foreach ( (array) $post_links as $url) :
 		if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
 			if ( $headers = wp_get_http_headers( $url) ) {
 				$len = (int) $headers['content-length'];
@@ -1044,7 +1044,7 @@
 function merge_filters($tag) {
 	global $wp_filter;
 	if ( isset($wp_filter['all']) ) {
-		foreach ($wp_filter['all'] as $priority => $functions) {
+		foreach ( (array) $wp_filter['all'] as $priority => $functions) {
 			if ( isset($wp_filter[$tag][$priority]) )
 				$wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
 			else
@@ -1067,9 +1067,9 @@
 	if ( !isset($wp_filter[$tag]) ) {
 		return $string;
 	}
-	foreach ($wp_filter[$tag] as $priority => $functions) {
+	foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
 		if ( !is_null($functions) ) {
-			foreach($functions as $function) {
+			foreach( (array) $functions as $function) {
 
 				$all_args = array_merge(array($string), $args);
 				$function_name = $function['function'];
@@ -1096,7 +1096,7 @@
 
 	// check that we don't already have the same filter at the same priority
 	if ( isset($wp_filter[$tag]["$priority"]) ) {
-		foreach($wp_filter[$tag]["$priority"] as $filter) {
+		foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
 			// uncomment if we want to match function AND accepted_args
 			// if ( $filter == array($function, $accepted_args) ) {
 			if ( $filter['function'] == $function_to_add ) {
@@ -1115,7 +1115,7 @@
 
 	// rebuild the list of filters
 	if ( isset($wp_filter[$tag]["$priority"]) ) {
-		foreach($wp_filter[$tag]["$priority"] as $filter) {
+		foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
 			if ( $filter['function'] != $function_to_remove ) {
 				$new_function_list[] = $filter;
 			}
@@ -1140,9 +1140,9 @@
 	if ( !isset($wp_filter[$tag]) ) {
 		return;
 	}
-	foreach ($wp_filter[$tag] as $priority => $functions) {
+	foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
 		if ( !is_null($functions) ) {
-			foreach($functions as $function) {
+			foreach( (array) $functions as $function) {
 
 				$function_name = $function['function'];
 				$accepted_args = $function['accepted_args'];
@@ -1213,7 +1213,7 @@
 		$incposts = preg_split('/[\s,]+/',$include);
 		$numberposts = count($incposts);  // only the number of posts included
 		if ( count($incposts) ) {
-			foreach ( $incposts as $incpost ) {
+			foreach ( (array) $incposts as $incpost ) {
 				if (empty($inclusions))
 					$inclusions = ' AND ( ID = ' . intval($incpost) . ' ';
 				else
@@ -1228,7 +1228,7 @@
 	if ( !empty($exclude) ) {
 		$exposts = preg_split('/[\s,]+/',$exclude);
 		if ( count($exposts) ) {
-			foreach ( $exposts as $expost ) {
+			foreach ( (array) $exposts as $expost ) {
 				if (empty($exclusions))
 					$exclusions = ' AND ( ID <> ' . intval($expost) . ' ';
 				else
@@ -1306,7 +1306,7 @@
 	if ( empty($dogs) )
 		return;
 
-	foreach ($dogs as $catt)
+	foreach ( (array) $dogs as $catt)
 		$category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
 }
 
@@ -1332,7 +1332,7 @@
 	if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
 		// Change from flat structure to hierarchical:
 		$post_meta_cache = array();
-		foreach ($meta_list as $metarow) {
+		foreach ( (array) $meta_list as $metarow) {
 			$mpid = $metarow['post_id'];
 			$mkey = $metarow['meta_key'];
 			$mval = $metarow['meta_value'];
@@ -1411,7 +1411,7 @@
 		$qs[func_get_arg(0)] = func_get_arg(1);
 	}
 
-	foreach($qs as $k => $v) {
+	foreach( (array) $qs as $k => $v) {
 		if ( $v != '' ) {
 			if ( $ret != '' )
 				$ret .= '&';
@@ -1429,7 +1429,7 @@
 function add_magic_quotes($array) {
 	global $wpdb;
 
-	foreach ($array as $k => $v) {
+	foreach ( (array) $array as $k => $v) {
 		if ( is_array($v) ) {
 			$array[$k] = add_magic_quotes($v);
 		} else {
@@ -1511,7 +1511,7 @@
 			return '';
 	}
 
-	foreach ($metas as $index => $meta) {
+	foreach ( (array) $metas as $index => $meta) {
 		@ $value = unserialize($meta->meta_value);
 		if ( $value === FALSE )
 			$value = $meta->meta_value;
Index: wp-includes/pluggable-functions.php
===================================================================
--- wp-includes/pluggable-functions.php	(revision 3839)
+++ wp-includes/pluggable-functions.php	(working copy)
@@ -77,7 +77,7 @@
 	$wpdb->show_errors();
 
 	if ($metavalues) {
-		foreach ( $metavalues as $meta ) {
+		foreach ( (array) $metavalues as $meta ) {
 			@ $value = unserialize($meta->meta_value);
 			if ($value === FALSE)
 				$value = $meta->meta_value;
@@ -130,7 +130,7 @@
 	$wpdb->show_errors();
 
 	if ($metavalues) {
-		foreach ( $metavalues as $meta ) {
+		foreach ( (array) $metavalues as $meta ) {
 			@ $value = unserialize($meta->meta_value);
 			if ($value === FALSE)
 				$value = $meta->meta_value;
@@ -265,7 +265,7 @@
 if ( !function_exists('check_ajax_referer') ) :
 function check_ajax_referer() {
 	$cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
-	foreach ( $cookie as $tasty ) {
+	foreach ( (array) $cookie as $tasty ) {
 		if ( false !== strpos($tasty, USER_COOKIE) )
 			$user = substr(strstr($tasty, '='), 1);
 		if ( false !== strpos($tasty, PASS_COOKIE) )
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 3839)
+++ wp-includes/script-loader.php	(working copy)
@@ -84,7 +84,7 @@
 		if ( ! $handles = (array) $handles )
 			return array();
 		$return = array();
-		foreach ( $handles as $handle ) {
+		foreach ( (array) $handles as $handle ) {
 			$handle = explode('?', $handle);
 			if ( isset($handle[1]) )
 				$this->args[$handle[0]] = $handle[1];
Index: wp-includes/feed-functions.php
===================================================================
--- wp-includes/feed-functions.php	(revision 3839)
+++ wp-includes/feed-functions.php	(working copy)
@@ -131,7 +131,7 @@
 function the_category_rss($type = 'rss') {
     $categories = get_the_category();
     $the_list = '';
-    foreach ($categories as $category) {
+    foreach ( (array) $categories as $category) {
         $category->cat_name = convert_chars($category->cat_name);
         if ('rdf' == $type) {
             $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
@@ -151,7 +151,7 @@
 		while( list( $key, $val ) = each( $custom_fields ) ) { 
 			if( $key == 'enclosure' ) {
 				if (is_array($val)) {
-					foreach($val as $enc) {
+					foreach( (array) $val as $enc) {
 						$enclosure = split( "\n", $enc );
 						print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
 					}
Index: wp-includes/vars.php
===================================================================
--- wp-includes/vars.php	(revision 3839)
+++ wp-includes/vars.php	(working copy)
@@ -92,7 +92,7 @@
 
 
 // generates smilies' search & replace arrays
-foreach($wpsmiliestrans as $smiley => $img) {
+foreach( (array) $wpsmiliestrans as $smiley => $img) {
 	$wp_smiliessearch[] = $smiley;
 	$smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
 	$wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
Index: wp-includes/rss-functions.php
===================================================================
--- wp-includes/rss-functions.php	(revision 3839)
+++ wp-includes/rss-functions.php	(working copy)
@@ -524,7 +524,7 @@
 	if ( $rss and !$rss->ERROR) {
 
 		// find Etag, and Last-Modified
-		foreach($resp->headers as $h) {
+		foreach( (array) $resp->headers as $h) {
 			// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
 			if (strpos($h, ": ")) {
 				list($field, $val) = explode(": ", $h, 2);
@@ -823,7 +823,7 @@
 		if ( $rss ) {
 			echo "<ul>";
 			$rss->items = array_slice($rss->items, 0, $num_items);
-				foreach ($rss->items as $item ) {
+				foreach ( (array) $rss->items as $item ) {
 					echo "<li>\n";
 					echo "<a href='$item[link]' title='$item[description]'>";
 					echo htmlentities($item['title']);
@@ -841,7 +841,7 @@
 	$rss = fetch_rss($url);
 	if ( $rss ) {
 		$rss->items = array_slice($rss->items, 0, $num_items);
-		foreach ($rss->items as $item ) {
+		foreach ( (array) $rss->items as $item ) {
 			echo "<li>\n";
 			echo "<a href='$item[link]' title='$item[description]'>";
 			echo htmlentities($item['title']);
Index: wp-includes/template-functions-author.php
===================================================================
--- wp-includes/template-functions-author.php	(revision 3839)
+++ wp-includes/template-functions-author.php	(working copy)
@@ -179,7 +179,7 @@
 	$query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
 	$authors = $wpdb->get_results($query);
 
-	foreach ( $authors as $author ) {
+	foreach ( (array) $authors as $author ) {
 		$author = get_userdata( $author->ID );
 		$posts = get_usernumposts($author->ID);
 		$name = $author->nickname;
Index: xmlrpc.php
===================================================================
--- xmlrpc.php	(revision 3839)
+++ xmlrpc.php	(working copy)
@@ -157,7 +157,7 @@
 	function escape(&$array) {
 		global $wpdb;
 
-		foreach ($array as $k => $v) {
+		foreach ( (array) $array as $k => $v) {
 			if (is_array($v)) {
 				$this->escape($array[$k]);
 			} else if (is_object($v)) {
@@ -282,7 +282,7 @@
 	    return $this->error;
 	  }
 
-	  foreach ($posts_list as $entry) {
+	  foreach ( (array) $posts_list as $entry) {
 	  
 	    $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
 	    $categories = implode(',', wp_get_post_cats(1, $entry['ID']));
@@ -573,7 +573,7 @@
 	  $post_category = array();
 
 	  if (is_array($catnames)) {
-	    foreach ($catnames as $cat) {
+	    foreach ( (array) $catnames as $cat) {
 	      $post_category[] = get_cat_ID($cat);
 	    }
 	  }
@@ -625,7 +625,7 @@
 	  $post_category = array();
 
 	  if (is_array($catnames)) {
-	    foreach ($catnames as $cat) {
+	    foreach ( (array) $catnames as $cat) {
 	      $post_category[] = get_cat_ID($cat);
 	    }
 	  }
@@ -696,7 +696,7 @@
 
 	    $categories = array();
 	    $catids = wp_get_post_cats('', $post_ID);
-	    foreach($catids as $catid) {
+	    foreach( (array) $catids as $catid) {
 	      $categories[] = get_cat_name($catid);
 	    }
 
@@ -751,12 +751,12 @@
 	    return $this->error;
 	  }
 
-	  foreach ($posts_list as $entry) {
+	  foreach ( (array) $posts_list as $entry) {
 	  
 	    $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
 	    $categories = array();
 	    $catids = wp_get_post_cats('', $entry['ID']);
-	    foreach($catids as $catid) {
+	    foreach( (array) $catids as $catid) {
 	      $categories[] = get_cat_name($catid);
 	    }
 
@@ -813,7 +813,7 @@
 
 	  // FIXME: can we avoid using direct SQL there?
 	  if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
-	    foreach ($cats as $cat) {
+	    foreach ( (array) $cats as $cat) {
 	      $struct['categoryId'] = $cat['cat_ID'];
 	      $struct['description'] = $cat['cat_name'];
 	      $struct['categoryName'] = $cat['cat_name'];
@@ -891,7 +891,7 @@
 	    return $this->error;
 	  }
 
-	  foreach ($posts_list as $entry) {
+	  foreach ( (array) $posts_list as $entry) {
 	  
 	    $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
 
@@ -932,7 +932,7 @@
 
 	  // FIXME: can we avoid using direct SQL there?
 	  if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
-	    foreach ($cats as $cat) {
+	    foreach ( (array) $cats as $cat) {
 	      $struct['categoryId'] = $cat['cat_ID'];
 	      $struct['categoryName'] = $cat['cat_name'];
 
@@ -961,7 +961,7 @@
 	  $catids = wp_get_post_cats('', intval($post_ID));
 	  // first listed category will be the primary category
 	  $isPrimary = true;
-	  foreach($catids as $catid) {
+	  foreach( (array) $catids as $catid) {
 	    $categories[] = array(
 	      'categoryName' => get_cat_name($catid),
 	      'categoryId' => $catid,
@@ -992,7 +992,7 @@
 	  if ( !current_user_can('edit_post', $post_ID) )
 	    return new IXR_Error(401, 'Sorry, you can not edit this post.');
 
-	  foreach($categories as $cat) {
+	  foreach( (array) $categories as $cat) {
 	    $catids[] = $cat['categoryId'];
 	  }
 
@@ -1006,7 +1006,7 @@
 	function mt_supportedMethods($args) {
 
 	  $supported_methods = array();
-	  foreach($this->methods as $key=>$value) {
+	  foreach( (array) $this->methods as $key=>$value) {
 	    $supported_methods[] = $key;
 	  }
 
@@ -1041,7 +1041,7 @@
 	  }
 
 	  $trackback_pings = array();
-	  foreach($comments as $comment) {
+	  foreach( (array) $comments as $comment) {
 	    if ( 'trackback' == $comment->comment_type ) {
 	      $content = $comment->comment_content;
 	      $title = substr($content, 8, (strpos($content, '</strong>') - 8));
@@ -1205,7 +1205,7 @@
 		$link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom );
 
 		$finished = false;
-		foreach ( $p as $para ) {
+		foreach ( (array) $p as $para ) {
 			if ( $finished )
 				continue;
 			if ( strstr( $para, $pagelinkedto ) ) {
@@ -1274,7 +1274,7 @@
 		}
 
 		$pingbacks = array();
-		foreach($comments as $comment) {
+		foreach( (array) $comments as $comment) {
 			if ( 'pingback' == $comment->comment_type )
 				$pingbacks[] = $comment->comment_author_url;
 		}
Index: wp-mail.php
===================================================================
--- wp-mail.php	(revision 3839)
+++ wp-mail.php	(working copy)
@@ -30,7 +30,7 @@
 	$bodysignal = 0;
 	$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
 					 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
-	foreach ($message as $line) :
+	foreach ( (array) $message as $line) :
 		if (strlen($line) < 3) $bodysignal = 1;
 
 		if ($bodysignal) {
Index: wp-content/plugins/wp-db-backup.php
===================================================================
--- wp-content/plugins/wp-db-backup.php	(revision 3839)
+++ wp-content/plugins/wp-db-backup.php	(working copy)
@@ -81,7 +81,7 @@
 					<script type="text/javascript"><!--\\
 				';
 				if($this->backup_errors) {
-					foreach($this->backup_errors as $error) {
+					foreach( (array) $this->backup_errors as $error) {
 						echo "window.parent.addError('$error');\n";
 					}
 				}
@@ -198,7 +198,7 @@
 		$core_tables = $_POST['core_tables'];
 		$tables = array_merge($core_tables, $also_backup);
 		$step_count = 1;
-		foreach ($tables as $table) {
+		foreach ( (array) $tables as $table) {
 			$rec_count = $wpdb->get_var("SELECT count(*) FROM {$table}");
 			$rec_segments = ceil($rec_count / ROWS_PER_SEGMENT);
 			$table_count = 0;
@@ -279,7 +279,7 @@
 		if($this->fp) $this->close($this->fp);
 
 		if($this->backup_errors) {
-			foreach($this->backup_errors as $error) {
+			foreach( (array) $this->backup_errors as $error) {
 				echo "window.parent.addError('$error');\n";
 			}
 		}
@@ -472,7 +472,7 @@
 
 		if(($segment == 'none') || ($segment >= 0)) {
 			$ints = array();
-			foreach ($table_structure as $struct) {
+			foreach ( (array) $table_structure as $struct) {
 				if ( (0 === strpos($struct->Type, 'tinyint')) ||
 					(0 === strpos(strtolower($struct->Type), 'smallint')) ||
 					(0 === strpos(strtolower($struct->Type), 'mediumint')) ||
@@ -510,9 +510,9 @@
 				$search = array("\x00", "\x0a", "\x0d", "\x1a");
 				$replace = array('\0', '\n', '\r', '\Z');
 				if($table_data) {
-					foreach ($table_data as $row) {
+					foreach ( (array) $table_data as $row) {
 						$values = array();
-						foreach ($row as $key => $value) {
+						foreach ( (array) $row as $key => $value) {
 							if ($ints[strtolower($key)]) {
 								$values[] = $value;
 							} else {
@@ -588,7 +588,7 @@
 		else
 			$tables = $core_tables;
 
-		foreach ($tables as $table) {
+		foreach ( (array) $tables as $table) {
 			// Increase script execution time-limit to 15 min for every table.
 			if ( !ini_get('safe_mode')) @set_time_limit(15*60);
 			// Create the SQL statements
@@ -702,7 +702,7 @@
 
 		if (count($this->backup_errors)) {
 			$feedback .= '<div class="updated error">' . __('The following errors were reported:') . "<pre>";
-			foreach($this->backup_errors as $error) {
+			foreach( (array) $this->backup_errors as $error) {
 				$feedback .= "{$error}\n";  //Errors are already localized
 			}
 			$feedback .= "</pre></div>";
@@ -763,13 +763,13 @@
 		echo '<form method="post">';
 		echo '<table align="center" cellspacing="5" cellpadding="5"><tr><td width="50%" align="left" class="alternate" valign="top">';
 		echo __('These core WordPress tables will always be backed up:') . '<br /><ul>';
-		foreach ($wp_backup_default_tables as $table) {
+		foreach ( (array) $wp_backup_default_tables as $table) {
 			echo "<li><input type='hidden' name='core_tables[]' value='$table' />$table</li>";
 		}
 		echo '</ul></td><td width="50%" align="left" valign="top">';
 		if (count($other_tables) > 0) {
 			echo __('You may choose to include any of the following tables:') . ' <br />';
-			foreach ($other_tables as $table) {
+			foreach ( (array) $other_tables as $table) {
 				echo "<label style=\"display:block;\"><input type='checkbox' name='other_tables[]' value='{$table}' /> {$table}</label>";
 			}
 		}
@@ -784,7 +784,7 @@
 		// Check DB dize.
 		$table_status = $wpdb->get_results("SHOW TABLE STATUS FROM " . $this->backquote(DB_NAME));
 		$core_size = $db_size = 0;
-		foreach($table_status as $table) {
+		foreach( (array) $table_status as $table) {
 			$table_size = $table->Data_length - $table->Data_free;
 			if(in_array($table->Name, $wp_backup_default_tables)) {
 				$core_size += $table_size;
@@ -816,7 +816,7 @@
 			echo __('Schedule: ');
 			$wp_cron_backup_schedule = get_option('wp_cron_backup_schedule');
 			$schedule = array(0 => __('None'), 1 => __('Daily'));
-			foreach ($schedule as $value => $name) {
+			foreach ( (array) $schedule as $value => $name) {
 				echo ' <input type="radio" name="cron_schedule"';
 				if ($wp_cron_backup_schedule == $value) {
 					echo ' checked="checked" ';
@@ -836,7 +836,7 @@
 			}
 			if (count($other_tables) > 0) {
 				echo '<tr><td colspan="2" align="left">' . __('Tables to include:') . '<br />';
-				foreach ($other_tables as $table) {
+				foreach ( (array) $other_tables as $table) {
 					echo '<input type="checkbox" ';
 					if (in_array($table, $cron_tables)) {
 						echo 'checked=checked ';
Index: wp-content/themes/classic/comments.php
===================================================================
--- wp-content/themes/classic/comments.php	(revision 3839)
+++ wp-content/themes/classic/comments.php	(working copy)
@@ -11,7 +11,7 @@
 <?php if ( $comments ) : ?>
 <ol id="commentlist">
 
-<?php foreach ($comments as $comment) : ?>
+<?php foreach ( (array) $comments as $comment) : ?>
 	<li id="comment-<?php comment_ID() ?>">
 	<?php comment_text() ?>
 	<p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
Index: wp-content/themes/classic/comments-popup.php
===================================================================
--- wp-content/themes/classic/comments-popup.php	(revision 3839)
+++ wp-content/themes/classic/comments-popup.php	(working copy)
@@ -1,7 +1,7 @@
 <?php 
 /* Don't remove these lines. */
 add_filter('comment_text', 'popuplinks');
-foreach ($posts as $post) { start_wp();
+foreach ( (array) $posts as $post) { start_wp();
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -40,7 +40,7 @@
 
 <?php if ($comments) { ?>
 <ol id="commentlist">
-<?php foreach ($comments as $comment) { ?>
+<?php foreach ( (array) $comments as $comment) { ?>
 	<li id="comment-<?php comment_ID() ?>">
 	<?php comment_text() ?>
 	<p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
Index: wp-content/themes/default/footer.php
===================================================================
--- wp-content/themes/default/footer.php	(revision 3839)
+++ wp-content/themes/default/footer.php	(working copy)
@@ -14,6 +14,9 @@
 <!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ -->
 <?php /* "Just what do you think you're doing Dave?" */ ?>
 
+<!--
+<?php print_r($wpdb->queries); ?>
+-->
 		<?php wp_footer(); ?>
 </body>
 </html>
Index: wp-content/themes/default/images/header-img.php
===================================================================
--- wp-content/themes/default/images/header-img.php	(revision 3839)
+++ wp-content/themes/default/images/header-img.php	(working copy)
@@ -9,9 +9,9 @@
 // Assign and validate the color values
 $default = false;
 $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
-foreach ( $vars as $var => $subvars ) {
+foreach ( (array) $vars as $var => $subvars ) {
 	if ( isset($_GET[$var]) ) {
-		foreach ( $subvars as $index => $subvar ) {
+		foreach ( (array) $subvars as $index => $subvar ) {
 			$length = strlen($_GET[$var]) / 3;
 			$v = substr($_GET[$var], $index * $length, $length);
 			if ( $length == 1 ) $v = '' . $v . $v;
Index: wp-content/themes/default/comments.php
===================================================================
--- wp-content/themes/default/comments.php	(revision 3839)
+++ wp-content/themes/default/comments.php	(working copy)
@@ -24,7 +24,7 @@
 
 	<ol class="commentlist">
 
-	<?php foreach ($comments as $comment) : ?>
+	<?php foreach ( (array) $comments as $comment) : ?>
 
 		<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
 			<cite><?php comment_author_link() ?></cite> Says:
Index: wp-content/themes/default/comments-popup.php
===================================================================
--- wp-content/themes/default/comments-popup.php	(revision 3839)
+++ wp-content/themes/default/comments-popup.php	(working copy)
@@ -1,7 +1,7 @@
 <?php 
 /* Don't remove these lines. */
 add_filter('comment_text', 'popuplinks');
-foreach ($posts as $post) { start_wp();
+foreach ( (array) $posts as $post) { start_wp();
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -40,7 +40,7 @@
 
 <?php if ($comments) { ?>
 <ol id="commentlist">
-<?php foreach ($comments as $comment) { ?>
+<?php foreach ( (array) $comments as $comment) { ?>
 	<li id="comment-<?php comment_ID() ?>">
 	<?php comment_text() ?>
 	<p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
Index: wp-register.php
===================================================================
--- wp-register.php	(revision 3839)
+++ wp-register.php	(working copy)
@@ -104,7 +104,7 @@
 <div class="error">
 	<p>
 	<?php
-	foreach($errors as $error) echo "$error<br />";
+	foreach( (array) $errors as $error) echo "$error<br />";
 	?>
 	</p>
 </div>
Index: wp-links-opml.php
===================================================================
--- wp-links-opml.php	(revision 3839)
+++ wp-links-opml.php	(working copy)
@@ -36,7 +36,7 @@
  $prev_cat_id = 0;
  $results = $wpdb->get_results($sql);
  if ($results) {
-     foreach ($results as $result) {
+     foreach ( (array) $results as $result) {
          if ($result->link_category != $prev_cat_id) { // new category
              if ($prev_cat_id != 0)  { // not first time
 ?>
Index: wp-rss2.php
===================================================================
--- wp-rss2.php	(revision 3839)
+++ wp-rss2.php	(working copy)
@@ -27,7 +27,7 @@
 	<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
 	<language><?php echo get_option('rss_language'); ?></language>
 	<?php do_action('rss2_head'); ?>
-	<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+	<?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
 	<item>
 		<title><?php the_title_rss() ?></title>
 		<link><?php permalink_single_rss() ?></link>
Index: wp-commentsrss2.php
===================================================================
--- wp-commentsrss2.php	(revision 3839)
+++ wp-commentsrss2.php	(working copy)
@@ -45,7 +45,7 @@
 		}
 	// this line is WordPress' motor, do not delete it.
 		if ($comments) {
-			foreach ($comments as $comment) {
+			foreach ( (array) $comments as $comment) {
 				$GLOBALS['comment'] =& $comment;
 				// Some plugins may need to know the metadata
 				// associated with this comment's post:
Index: wp-atom.php
===================================================================
--- wp-atom.php	(revision 3839)
+++ wp-atom.php	(working copy)
@@ -23,7 +23,7 @@
 	<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
 	<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
 	<?php do_action('atom_head'); ?>
-	<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+	<?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
 	<entry>
 	  	<author>
 			<name><?php the_author() ?></name>
Index: wp-settings.php
===================================================================
--- wp-settings.php	(revision 3839)
+++ wp-settings.php	(working copy)
@@ -11,7 +11,7 @@
 	$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
 
 	$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
-	foreach ( $input as $k => $v ) 
+	foreach ( (array) $input as $k => $v ) 
 		if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
 			unset($GLOBALS[$k]);
 }
@@ -173,7 +173,7 @@
 if ( get_settings('active_plugins') ) {
 	$current_plugins = get_settings('active_plugins');
 	if ( is_array($current_plugins) ) {
-		foreach ($current_plugins as $plugin) {
+		foreach ( (array) $current_plugins as $plugin) {
 			if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
 				include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
 		}
Index: wp-cron.php
===================================================================
--- wp-cron.php	(revision 3839)
+++ wp-cron.php	(working copy)
@@ -9,9 +9,9 @@
 $crons = get_option('cron');
 if (!is_array($crons) || array_shift(array_keys($crons)) > time())
 	return;
-foreach ($crons as $timestamp => $cronhooks) {
+foreach ( (array) $crons as $timestamp => $cronhooks) {
 	if ($timestamp > time()) break;
-	foreach($cronhooks as $hook => $args) {
+	foreach( (array) $cronhooks as $hook => $args) {
 		do_action($hook, $args['args']);
 		$schedule = $args['schedule'];
 		if($schedule != false) {
Index: wp-admin/menu-header.php
===================================================================
--- wp-admin/menu-header.php	(revision 3839)
+++ wp-admin/menu-header.php	(working copy)
@@ -5,7 +5,7 @@
 
 get_admin_page_parent();
 
-foreach ($menu as $item) {
+foreach ( (array) $menu as $item) {
 	$class = '';
 
 	// 0 = name, 1 = capability, 2 = file
@@ -28,7 +28,7 @@
 ?>
 <ul id="submenu">
 <?php 
-foreach ($submenu["$parent_file"] as $item) : 
+foreach ( (array) $submenu["$parent_file"] as $item) : 
 	 if ( !current_user_can($item[1]) )
 		 continue;
 
Index: wp-admin/inline-uploading.php
===================================================================
--- wp-admin/inline-uploading.php	(revision 3839)
+++ wp-admin/inline-uploading.php	(working copy)
@@ -198,7 +198,7 @@
 var filename = new Array();
 var icon = new Array();
 ";
-	foreach ( $attachments as $key => $attachment ) {
+	foreach ( (array) $attachments as $key => $attachment ) {
 		$ID = $attachment['ID'];
 		$href = get_attachment_link($ID);
 		$meta = get_post_meta($ID, '_wp_attachment_metadata', true);
Index: wp-admin/update-links.php
===================================================================
--- wp-admin/update-links.php	(revision 3839)
+++ wp-admin/update-links.php	(working copy)
@@ -35,7 +35,7 @@
     
 	$returns = explode("\n", $body);
     
-	foreach ($returns as $return) :
+	foreach ( (array) $returns as $return) :
 		$time = $wpdb->escape( substr($return, 0, 19) );
 		$uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
 		$wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
Index: wp-admin/users.php
===================================================================
--- wp-admin/users.php	(revision 3839)
+++ wp-admin/users.php	(working copy)
@@ -22,7 +22,7 @@
 
  	$userids = $_POST['users'];
 	$update = 'promote';
- 	foreach($userids as $id) {
+ 	foreach( (array) $userids as $id) {
 		// The new role of the current user must also have edit_users caps
 		if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
 			$update = 'err_admin_role';
@@ -51,7 +51,7 @@
 	$userids = $_POST['users'];
 
 	$update = 'del';
- 	foreach ($userids as $id) {
+ 	foreach ( (array) $userids as $id) {
 		if($id == $current_user->id) {
 			$update = 'err_admin_del';
 			continue;
@@ -93,7 +93,7 @@
 <ul>
 <?php
 	$go_delete = false;
- 	foreach ($userids as $id) {
+ 	foreach ( (array) $userids as $id) {
  		$user = new WP_User($id);
 		if ($id == $current_user->id) {
 			echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
@@ -104,7 +104,7 @@
  	}
  	$all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
  	$user_dropdown = '<select name="reassign_user">';
- 	foreach ($all_logins as $login) {
+ 	foreach ( (array) $all_logins as $login) {
 		if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) {
  			$user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
  		}
@@ -149,7 +149,7 @@
 
 	$userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
 
-	foreach($userids as $userid) {
+	foreach( (array) $userids as $userid) {
 		$tmp_user = new WP_User($userid);
 		$roles = $tmp_user->roles;
 		$role = array_shift($roles);
@@ -194,7 +194,7 @@
 	<div class="error">
 		<ul>
 		<?php
-			foreach ( $errors->get_error_messages() as $message )
+			foreach ( (array) $errors->get_error_messages() as $message )
 				 echo "<li>$message</li>";
 		?>
 		</ul>
@@ -209,7 +209,7 @@
 	<h2><?php _e('User List by Role'); ?></h2>
 <table class="widefat">
 <?php
-foreach($roleclasses as $role => $roleclass) {
+foreach( (array) $roleclasses as $role => $roleclass) {
 	ksort($roleclass);
 ?>
 
@@ -229,7 +229,7 @@
 </thead>
 <tbody id="role-<?php echo $role; ?>"><?php
 $style = '';
-foreach ($roleclass as $user_object) {
+foreach ( (array) $roleclass as $user_object) {
 	$style = (' class="alternate"' == $style) ? '' : ' class="alternate"';
 	echo "\n\t" . user_row( $user_object, $style );
 }
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php	(revision 3839)
+++ wp-admin/edit-comments.php	(working copy)
@@ -54,7 +54,7 @@
 	check_admin_referer('bulk-comments');
 
 	$i = 0;
-	foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
+	foreach ( (array) $_POST['delete_comments'] as $comment) : // Check the permissions on each
 		$comment = (int) $comment;
 		$post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
 		// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
@@ -101,7 +101,7 @@
 
 		echo "<ol id='the-list' class='commentlist' $start>";
 		$i = 0;
-		foreach ($comments as $comment) {
+		foreach ( (array) $comments as $comment) {
 		++$i; $class = '';
 		$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
 			$comment_status = wp_get_comment_status($comment->comment_ID);
@@ -133,7 +133,7 @@
  | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
 		</li>
 
-<?php } // end foreach($comment) ?>
+<?php } // end foreach( (array) $comment) ?>
 </ol>
 
 <div id="ajax-response"></div>
@@ -163,7 +163,7 @@
 	<th scope="col" colspan="3">' .  __('Actions') . '</th>
   </tr>
 </thead>';
-		foreach ($comments as $comment) {
+		foreach ( (array) $comments as $comment) {
 		$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
 		$comment_status = wp_get_comment_status($comment->comment_ID);
 		$class = ('alternate' == $class) ? '' : 'alternate';
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 3839)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -121,7 +121,7 @@
 		die('-1');
 	$names = explode(',', $_POST['newcat']);
 	$r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
-	foreach ( $names as $cat_name ) {
+	foreach ( (array) $names as $cat_name ) {
 		$cat_name = trim($cat_name);
 		if ( !$category_nicename = sanitize_title($cat_name) )
 			die('0');
@@ -215,7 +215,7 @@
 	require_once( ABSPATH . WPINC . '/registration-functions.php');
 	$user_id = add_user();
 	if ( is_wp_error( $user_id ) ) {
-		foreach( $user_id->get_error_messages() as $message )
+		foreach( (array) $user_id->get_error_messages() as $message )
 			echo "$message<br />";
 	exit;
 	} elseif ( !$user_id ) {
Index: wp-admin/profile-update.php
===================================================================
--- wp-admin/profile-update.php	(revision 3839)
+++ wp-admin/profile-update.php	(working copy)
@@ -12,7 +12,7 @@
 $errors = edit_user($user_ID);
 
 if ( is_wp_error( $errors ) ) {
-	foreach( $errors->get_error_messages() as $message )
+	foreach( (array) $errors->get_error_messages() as $message )
 		echo "$message<br />";
 	exit;
 }
Index: wp-admin/install-helper.php
===================================================================
--- wp-admin/install-helper.php	(revision 3839)
+++ wp-admin/install-helper.php	(working copy)
@@ -10,7 +10,7 @@
  */
 function maybe_create_table($table_name, $create_ddl) {
     global $wpdb;
-    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
         if ($table == $table_name) {
             return true;
         }
@@ -18,7 +18,7 @@
     //didn't find it try to create it.
     $q = $wpdb->query($create_ddl);
     // we cannot directly tell that whether this succeeded!
-    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
         if ($table == $table_name) {
             return true;
         }
@@ -34,7 +34,7 @@
  */
 function maybe_add_column($table_name, $column_name, $create_ddl) {
     global $wpdb, $debug;
-    foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
         if ($debug) echo("checking $column == $column_name<br />");
         if ($column == $column_name) {
             return true;
@@ -43,7 +43,7 @@
     //didn't find it try to create it.
     $q = $wpdb->query($create_ddl);
     // we cannot directly tell that whether this succeeded!
-    foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
         if ($column == $column_name) {
             return true;
         }
@@ -60,12 +60,12 @@
  */
 function maybe_drop_column($table_name, $column_name, $drop_ddl) {
     global $wpdb;
-    foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
         if ($column == $column_name) {
             //found it try to drop it.
             $q = $wpdb->query($drop_ddl);
             // we cannot directly tell that whether this succeeded!
-            foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+            foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
                 if ($column == $column_name) {
                     return false;
                 }
@@ -96,7 +96,7 @@
     $diffs = 0;
     $results = $wpdb->get_results("DESC $table_name");
     
-    foreach ($results as $row ) {
+    foreach ( (array) $results as $row ) {
         if ($debug > 1) print_r($row);
         if ($row->Field == $col_name) {
             // got our column, check the params
Index: wp-admin/theme-editor.php
===================================================================
--- wp-admin/theme-editor.php	(revision 3839)
+++ wp-admin/theme-editor.php	(working copy)
@@ -93,7 +93,7 @@
 		<?php _e('Select theme to edit:') ?>
 		<select name="theme" id="theme">
 	<?php
-		foreach ($themes as $a_theme) {
+		foreach ( (array) $themes as $a_theme) {
 		$theme_name = $a_theme['Name'];
 		if ($theme_name == $theme) $selected = " selected='selected'";
 		else $selected = '';
@@ -121,7 +121,7 @@
 if ($allowed_files) :
 ?>
   <ul>
-<?php foreach($allowed_files as $allowed_file) : ?>
+<?php foreach( (array) $allowed_files as $allowed_file) : ?>
 		 <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
 <?php endforeach; ?>
   </ul>
Index: wp-admin/upgrade-functions.php
===================================================================
--- wp-admin/upgrade-functions.php	(revision 3839)
+++ wp-admin/upgrade-functions.php	(working copy)
@@ -187,7 +187,7 @@
 	// Get the title and ID of every post, post_name to check if it already has a value
 	$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
 	if ($posts) {
-		foreach($posts as $post) {
+		foreach( (array) $posts as $post) {
 			if ('' == $post->post_name) { 
 				$newtitle = sanitize_title($post->post_title);
 				$wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
@@ -196,7 +196,7 @@
 	}
 
 	$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
-	foreach ($categories as $category) {
+	foreach ( (array) $categories as $category) {
 		if ('' == $category->category_nicename) { 
 			$newtitle = sanitize_title($category->cat_name);
 			$wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
@@ -210,7 +210,7 @@
 
 	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
 	if ($done_ids) :
-		foreach ($done_ids as $done_id) :
+		foreach ( (array) $done_ids as $done_id) :
 			$done_posts[] = $done_id->post_id;
 		endforeach;
 		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
@@ -220,7 +220,7 @@
 
 	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
 	if ($allposts) :
-		foreach ($allposts as $post) {
+		foreach ( (array) $allposts as $post) {
 			// Check to see if it's already been imported
 			$cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
 			if (!$cat && 0 != $post->post_category) { // If there's no result
@@ -254,7 +254,7 @@
 
     // Set user_nicename.
 	$users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
- 	foreach ($users as $user) {
+ 	foreach ( (array) $users as $user) {
  		if ('' == $user->user_nicename) { 
  			$newname = sanitize_title($user->user_nickname);
  			$wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
@@ -262,7 +262,7 @@
  	}
 
 	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
-	foreach ($users as $row) {
+	foreach ( (array) $users as $row) {
 		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
 			   $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
 		}
@@ -311,7 +311,7 @@
     // Remove extraneous backslashes.
 	$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
 	if ($posts) {
-		foreach($posts as $post) {
+		foreach( (array) $posts as $post) {
             $post_content = addslashes(deslash($post->post_content));
             $post_title = addslashes(deslash($post->post_title));
             $post_excerpt = addslashes(deslash($post->post_excerpt));
@@ -327,7 +327,7 @@
     // Remove extraneous backslashes.
 	$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
 	if ($comments) {
-		foreach($comments as $comment) {
+		foreach( (array) $comments as $comment) {
             $comment_content = addslashes(deslash($comment->comment_content));
             $comment_author = addslashes(deslash($comment->comment_author));
             $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
@@ -337,7 +337,7 @@
     // Remove extraneous backslashes.
 	$links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
 	if ($links) {
-		foreach($links as $link) {
+		foreach( (array) $links as $link) {
             $link_name = addslashes(deslash($link->link_name));
             $link_description = addslashes(deslash($link->link_description));
             $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
@@ -370,7 +370,7 @@
 
 	// Some versions have multiple duplicate option_name rows with the same values
 	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
-	foreach ( $options as $option ) {
+	foreach ( (array) $options as $option ) {
 		if ( 1 != $option->dupes ) { // Could this be done in the query?
 			$limit = $option->dupes - 1;
 			$dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
@@ -388,7 +388,7 @@
 	populate_roles_160();
 
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
-	foreach ( $users as $user ) :
+	foreach ( (array) $users as $user ) :
 		if ( !empty( $user->user_firstname ) )
 			update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
 		if ( !empty( $user->user_lastname ) )
@@ -432,13 +432,13 @@
 	endforeach;
 	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
 	$wpdb->hide_errors();
-	foreach ( $old_user_fields as $old )
+	foreach ( (array) $old_user_fields as $old )
 		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
 	$wpdb->show_errors();
 
 	if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
 		$categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
-		foreach ( $categories as $cat_id ) {
+		foreach ( (array) $categories as $cat_id ) {
 			$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
 			$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
 		}
@@ -447,7 +447,7 @@
 	// populate comment_count field of posts table
 	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
 	if( is_array( $comments ) ) {
-		foreach ($comments as $comment) {
+		foreach ( (array) $comments as $comment) {
 			$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
 		}
 	}
@@ -456,7 +456,7 @@
 	// the mime type in post_type instead of post_mime_type.
 	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
 		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
-		foreach ($objects as $object) {
+		foreach ( (array) $objects as $object) {
 			$wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
 			post_mime_type = '$object->post_type',
 			post_type = ''
@@ -476,7 +476,7 @@
 		// Update status and type.
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
 
-		if ( ! empty($posts) ) foreach ($posts as $post) {
+		if ( ! empty($posts) ) foreach ( (array) $posts as $post) {
 			$status = $post->post_status;
 			$type = 'post';
 
@@ -503,14 +503,14 @@
 		
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
 		if ( !empty($posts) )
-			foreach ( $posts as $post )
+			foreach ( (array) $posts as $post )
 				wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', $post->ID);
 	}
 	if ( $wp_current_db_version < 3570 ) {
 		// Create categories for link categories if a category with the same
 		// name doesn't exist.  Create a map of link cat IDs to cat IDs.
 		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");	
-		foreach ( $link_cats as $link_cat) {
+		foreach ( (array) $link_cats as $link_cat) {
 			if ( $cat_id = category_exists($link_cat->cat_name) ) {
 				$link_cat_id_map[$link_cat->cat_id] = $cat_id;
 				$default_link_cat = $cat_id;
@@ -522,7 +522,7 @@
 
 		// Associate links to cats.
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
-		if ( !empty($links) ) foreach ( $links as $link ) {
+		if ( !empty($links) ) foreach ( (array) $links as $link ) {
 			$link_cat = $link_cat_id_map[$link->link_category];
 			$cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
 			if (!$cat && 0 != $link->link_category) {
@@ -537,7 +537,7 @@
 		// Count links per category.
 		if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
 			$categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
-			foreach ( $categories as $cat_id ) {
+			foreach ( (array) $categories as $cat_id ) {
 				$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
 				$wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
 			}
@@ -550,7 +550,7 @@
 // General
 function maybe_create_table($table_name, $create_ddl) {
     global $wpdb;
-    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
         if ($table == $table_name) {
             return true;
         }
@@ -558,7 +558,7 @@
     //didn't find it try to create it.
     $q = $wpdb->query($create_ddl);
     // we cannot directly tell that whether this succeeded!
-    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
         if ($table == $table_name) {
             return true;
         }
@@ -593,7 +593,7 @@
  */
 function maybe_add_column($table_name, $column_name, $create_ddl) {
     global $wpdb, $debug;
-    foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+    foreach ( (array) $wpdb->get_col("DESC $table_name", 0) as $column ) {
         if ($debug) echo("checking $column == $column_name<br />");
         if ($column == $column_name) {
             return true;
@@ -602,7 +602,7 @@
     //didn't find it try to create it.
     $q = $wpdb->query($create_ddl);
     // we cannot directly tell that whether this succeeded!
-    foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+    foreach ( (array) $wpdb->get_col("DESC $table_name", 0) as $column ) {
         if ($column == $column_name) {
             return true;
         }
@@ -615,7 +615,7 @@
 function get_alloptions_110() {
 	global $wpdb;
 	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
-		foreach ($options as $option) {
+		foreach ( (array) $options as $option) {
 			// "When trying to design a foolproof system, 
 			//  never underestimate the ingenuity of the fools :)" -- Dougal
 			if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
@@ -677,7 +677,7 @@
 	$for_update = array();
 
 	// Create a tablename index for an array ($cqueries) of queries
-	foreach($queries as $qry) {
+	foreach( (array) $queries as $qry) {
 		if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
 			$cqueries[strtolower($matches[1])] = $qry;
 			$for_update[$matches[1]] = 'Created table '.$matches[1];
@@ -699,7 +699,7 @@
 	// Check to see which tables and fields exist
 	if($tables = $wpdb->get_col('SHOW TABLES;')) {
 		// For every table in the database
-		foreach($tables as $table) {
+		foreach( (array) $tables as $table) {
 			// If a table query exists for the database table...
 			if( array_key_exists(strtolower($table), $cqueries) ) {
 				// Clear the field and index arrays
@@ -715,7 +715,7 @@
 				//echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
 
 				// For every field line specified in the query
-				foreach($flds as $fld) {
+				foreach( (array) $flds as $fld) {
 					// Extract the field name
 					preg_match("|^([^ ]*)|", trim($fld), $fvals);
 					$fieldname = $fvals[1];
@@ -746,7 +746,7 @@
 				$tablefields = $wpdb->get_results("DESCRIBE {$table};");
 
 				// For every field in the table
-				foreach($tablefields as $tablefield) {
+				foreach( (array) $tablefields as $tablefield) {
 					// If the table field exists in the field array...
 					if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
 						// Get the field type from the query
@@ -781,7 +781,7 @@
 				}
 
 				// For every remaining field specified for the table
-				foreach($cfields as $fieldname => $fielddef) {
+				foreach( (array) $cfields as $fieldname => $fielddef) {
 					// Push a query line into $cqueries that adds the field to that table
 					$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
 					$for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
@@ -796,7 +796,7 @@
 					unset($index_ary);
 
 					// For every index in the table
-					foreach($tableindices as $tableindex) {
+					foreach( (array) $tableindices as $tableindex) {
 						// Add the index to the index data array
 						$keyname = $tableindex->Key_name;
 						$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
@@ -804,7 +804,7 @@
 					}
 
 					// For each actual index in the index array
-					foreach($index_ary as $index_name => $index_data) {
+					foreach( (array) $index_ary as $index_name => $index_data) {
 						// Build a create string to compare to the query
 						$index_string = '';
 						if($index_name == 'PRIMARY') {
@@ -819,7 +819,7 @@
 						}
 						$index_columns = '';
 						// For each column in the index
-						foreach($index_data['columns'] as $column_data) {
+						foreach( (array) $index_data['columns'] as $column_data) {
 							if($index_columns != '') $index_columns .= ',';
 							// Add the field to the column list string
 							$index_columns .= $column_data['fieldname'];
@@ -839,7 +839,7 @@
 				}
 
 				// For every remaining index specified for the table
-				foreach($indices as $index) {
+				foreach( (array) $indices as $index) {
 					// Push a query line into $cqueries that adds the index to that table
 					$cqueries[] = "ALTER TABLE {$table} ADD $index";
 					$for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
@@ -856,7 +856,7 @@
 
 	$allqueries = array_merge($cqueries, $iqueries);
 	if($execute) {
-		foreach($allqueries as $query) {
+		foreach( (array) $allqueries as $query) {
 			//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
 			$wpdb->query($query);
 		}
@@ -870,7 +870,7 @@
 
 	$alterations = dbDelta($wp_queries);
 	echo "<ol>\n";
-	foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+	foreach( (array) $alterations as $alteration) echo "<li>$alteration</li>\n";
 	echo "</ol>\n";
 }
 
@@ -892,7 +892,7 @@
 	// standard WP files are copied.
 	$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
 
-	foreach ($files as $oldfile => $newfile) {
+	foreach ( (array) $files as $oldfile => $newfile) {
 		if ($oldfile == 'index.php')
 			$oldpath = $home_path;
 		else
@@ -917,7 +917,7 @@
 		if ($lines) {
 			$f = fopen("$site_dir/$newfile", 'w');
 
-			foreach ($lines as $line) {
+			foreach ( (array) $lines as $line) {
 				if (preg_match('/require.*wp-blog-header/', $line))
 					$line = '//' . $line;
 
@@ -971,7 +971,7 @@
 	if ($stylelines) {
 		$f = fopen("$site_dir/style.css", 'w');
 
-		foreach ($stylelines as $line) {
+		foreach ( (array) $stylelines as $line) {
 			if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name";
 			elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');
 			elseif (strstr($line, "Description:")) $line = "Description: Your theme";
Index: wp-admin/templates.php
===================================================================
--- wp-admin/templates.php	(revision 3839)
+++ wp-admin/templates.php	(working copy)
@@ -107,7 +107,7 @@
 <h3><?php _e('Recent'); ?></h3>
 <?php
 echo '<ol>';
-foreach ($recents as $recent) :
+foreach ( (array) $recents as $recent) :
 	echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
 endforeach;
 echo '</ol>';
@@ -116,12 +116,12 @@
 <h3><?php _e('Common'); ?></h3>
 	<?php $common_files = array('index.php', '.htaccess', 'my-hacks.php');
  $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php');
- foreach ($old_files as $old_file) {
+ foreach ( (array) $old_files as $old_file) {
 	 if (file_exists(ABSPATH . $old_file))
 		 $common_files[] = $old_file;
  } ?>
   <ul>
-	 <?php foreach ($common_files as $common_file) : ?>
+	 <?php foreach ( (array) $common_files as $common_file) : ?>
 	  <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
 	 <?php endforeach; ?>
   </ul>
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revision 3839)
+++ wp-admin/admin-functions.php	(working copy)
@@ -115,7 +115,7 @@
 
 	$i = 0;
 	$search = "# id=(\"|')p(\d+)\\1#i";
-	foreach ( $anchor_matches[0] as $anchor ) {
+	foreach ( (array) $anchor_matches[0] as $anchor ) {
 		if ( 0 == preg_match($search, $anchor, $id_matches) )
 			continue;
 
@@ -225,12 +225,12 @@
 
 	// Meta Stuff
 	if ($_POST['meta']) {
-		foreach ($_POST['meta'] as $key => $value)
+		foreach ( (array) $_POST['meta'] as $key => $value)
 			update_meta($key, $value['key'], $value['value']);
 	}
 
 	if ($_POST['deletemeta']) {
-		foreach ($_POST['deletemeta'] as $key => $value)
+		foreach ( (array) $_POST['deletemeta'] as $key => $value)
 			delete_meta($key);
 	}
 
@@ -364,7 +364,7 @@
 function wp_dropdown_roles( $default = false ) {
 	global $wp_roles;
 	$r = '';
-	foreach($wp_roles->role_names as $role => $name)
+	foreach( (array) $wp_roles->role_names as $role => $name)
 		if ( $default == $role ) // Make default first in list
 			$p = "\n\t<option selected='selected' value='$role'>$name</option>";
 		else
@@ -609,7 +609,7 @@
 	$result = array ();
 
 	if (is_array($cats)) {
-		foreach ($cats as $cat) {
+		foreach ( (array) $cats as $cat) {
 			$result[$cat]['children'] = get_nested_categories($default, $cat);
 			$result[$cat]['cat_ID'] = $cat;
 			$result[$cat]['checked'] = in_array($cat, $checked_categories);
@@ -623,7 +623,7 @@
 }
 
 function write_nested_categories($categories) {
-	foreach ($categories as $category) {
+	foreach ( (array) $categories as $category) {
 		echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";
 
 		if ( $category['children'] ) {
@@ -646,7 +646,7 @@
 		$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
 
 	if ($categories) {
-		foreach ($categories as $category) {
+		foreach ( (array) $categories as $category) {
 			if ($category->category_parent == $parent) {
 				$category->cat_name = wp_specialchars($category->cat_name,'double');
 				$pad = str_repeat('&#8212; ', $level);
@@ -690,7 +690,7 @@
 	if (! $pages)
 		return false;
 
-	foreach ($pages as $post) {
+	foreach ( (array) $pages as $post) {
 		setup_postdata($post);
 		if ( $hierarchy && ($post->post_parent != $parent) )
 			continue;
@@ -750,7 +750,7 @@
 		$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
 	}
 	if ($categories) {
-		foreach ($categories as $category) {
+		foreach ( (array) $categories as $category) {
 			if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
 				$pad = str_repeat('&#8211; ', $level);
 				$category->cat_name = wp_specialchars($category->cat_name);
@@ -895,7 +895,7 @@
 	</thead>
 <?php
 	$r ="\n\t<tbody id='the-list'>";
-	foreach ($meta as $entry) {
+	foreach ( (array) $meta as $entry) {
 		++ $count;
 		if ($count % 2)
 			$style = 'alternate';
@@ -954,7 +954,7 @@
 <option value="#NONE#"><?php _e('- Select -'); ?></option>
 <?php
 
-	foreach ($keys as $key) {
+	foreach ( (array) $keys as $key) {
 		echo "\n\t<option value='$key'>$key</option>";
 	}
 ?>
@@ -1080,7 +1080,7 @@
 		$foundit = false;
 		if ($markerdata) {
 			$state = true;
-			foreach ($markerdata as $n => $markerline) {
+			foreach ( (array) $markerdata as $n => $markerline) {
 				if (strstr($markerline, "# BEGIN {$marker}"))
 					$state = false;
 				if ($state) {
@@ -1092,7 +1092,7 @@
 				if (strstr($markerline, "# END {$marker}")) {
 					fwrite($f, "# BEGIN {$marker}\n");
 					if (is_array($insertion))
-						foreach ($insertion as $insertline)
+						foreach ( (array) $insertion as $insertline)
 							fwrite($f, "{$insertline}\n");
 					fwrite($f, "# END {$marker}\n");
 					$state = true;
@@ -1102,7 +1102,7 @@
 		}
 		if (!$foundit) {
 			fwrite($f, "# BEGIN {$marker}\n");
-			foreach ($insertion as $insertline)
+			foreach ( (array) $insertion as $insertline)
 				fwrite($f, "{$insertline}\n");
 			fwrite($f, "# END {$marker}\n");
 		}
@@ -1126,7 +1126,7 @@
 	if ($markerdata = explode("\n", implode('', file($filename))));
 	{
 		$state = false;
-		foreach ($markerdata as $markerline) {
+		foreach ( (array) $markerdata as $markerline) {
 			if (strstr($markerline, "# END {$marker}"))
 				$state = false;
 			if ($state)
@@ -1248,7 +1248,7 @@
 	$page_templates = array ();
 
 	if (is_array($templates)) {
-		foreach ($templates as $template) {
+		foreach ( (array) $templates as $template) {
 			$template_data = implode('', file(ABSPATH.$template));
 			preg_match("|Template Name:(.*)|i", $template_data, $name);
 			preg_match("|Description:(.*)|i", $template_data, $description);
@@ -1281,7 +1281,7 @@
 	$items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
 
 	if ($items) {
-		foreach ($items as $item) {
+		foreach ( (array) $items as $item) {
 			// A page cannot be it's own parent.
 			if (!empty ($post_ID)) {
 				if ($item->ID == $post_ID) {
@@ -1317,7 +1317,7 @@
 		return true;
 
 	if (isset ($submenu[$parent])) {
-		foreach ($submenu[$parent] as $submenu_array) {
+		foreach ( (array) $submenu[$parent] as $submenu_array) {
 			if ($submenu_array[2] == $pagenow) {
 				if (current_user_can($submenu_array[1]))
 					return true;
@@ -1327,7 +1327,7 @@
 		}
 	}
 
-	foreach ($menu as $menu_array) {
+	foreach ( (array) $menu as $menu_array) {
 		//echo "parent array: " . $menu_array[2];
 		if ($menu_array[2] == $parent) {
 			if (current_user_can($menu_array[1]))
@@ -1355,7 +1355,7 @@
 
 	$parent = $parent1 = get_admin_page_parent();
 	if (empty ($parent)) {
-		foreach ($menu as $menu_array) {
+		foreach ( (array) $menu as $menu_array) {
 			if (isset ($menu_array[3])) {
 				if ($menu_array[2] == $pagenow) {
 					$title = $menu_array[3];
@@ -1369,7 +1369,7 @@
 		}
 	} else {
 		foreach (array_keys($submenu) as $parent) {
-			foreach ($submenu[$parent] as $submenu_array) {
+			foreach ( (array) $submenu[$parent] as $submenu_array) {
 				if (isset ($submenu_array[3])) {
 					if ($submenu_array[2] == $pagenow) {
 						$title = $submenu_array[3];
@@ -1403,7 +1403,7 @@
 	}
 
 	if ($pagenow == 'admin.php' && isset ($plugin_page)) {
-		foreach ($menu as $parent_menu) {
+		foreach ( (array) $menu as $parent_menu) {
 			if ($parent_menu[2] == $plugin_page) {
 				$parent_file = $plugin_page;
 				if ( isset($real_parent_file[$parent_file]) )
@@ -1415,7 +1415,7 @@
 	}
 
 	foreach (array_keys($submenu) as $parent) {
-		foreach ($submenu[$parent] as $submenu_array) {
+		foreach ( (array) $submenu[$parent] as $submenu_array) {
 			if ( isset($real_parent_file[$parent]) )
 				$parent = $real_parent_file[$parent];
 			if ($submenu_array[2] == $pagenow) {
@@ -1465,7 +1465,7 @@
 	// parent file someone is trying to link back to the parent manually.  In
 	// this case, don't automatically add a link back to avoid duplication.
 	if (!isset ($submenu[$parent]) && $file != $parent) {
-		foreach ($menu as $parent_menu) {
+		foreach ( (array) $menu as $parent_menu) {
 			if ($parent_menu[2] == $parent) {
 				$submenu[$parent][] = $parent_menu;
 			}
@@ -1654,7 +1654,7 @@
 
 	sort($plugin_files);
 
-	foreach ($plugin_files as $plugin_file) {
+	foreach ( (array) $plugin_files as $plugin_file) {
 		if ( !is_readable("$plugin_root/$plugin_file"))
 			continue;
 
@@ -1844,7 +1844,7 @@
 	if ( $test_type ) {
 		$type = false;
 		$ext = false;
-		foreach ($mimes as $ext_preg => $mime_match) {
+		foreach ( (array) $mimes as $ext_preg => $mime_match) {
 			$ext_preg = '![^.]\.(' . $ext_preg . ')$!i';
 			if ( preg_match($ext_preg, $file['name'], $ext_matches) ) {
 				$type = $mime_match;
Index: wp-admin/edit-page-form.php
===================================================================
--- wp-admin/edit-page-form.php	(revision 3839)
+++ wp-admin/edit-page-form.php	(working copy)
@@ -104,7 +104,7 @@
 <div class="dbx-content">
 <select name="post_author_override" id="post_author_override">
 <?php 
-foreach ($authors as $o) :
+foreach ( (array) $authors as $o) :
 $o = get_userdata( $o->ID );
 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
 else $selected = '';
Index: wp-admin/moderation.php
===================================================================
--- wp-admin/moderation.php	(revision 3839)
+++ wp-admin/moderation.php	(working copy)
@@ -23,7 +23,7 @@
 
 $comment = array();
 if (isset($_POST["comment"])) {
-	foreach ($_POST["comment"] as $k => $v) {
+	foreach ( (array) $_POST["comment"] as $k => $v) {
 		$comment[intval($k)] = $v;
 	}
 }
@@ -42,7 +42,7 @@
 	$item_approved = 0;
 	$item_spam = 0;
 
-	foreach($comment as $key => $value) {
+	foreach( (array) $comment as $key => $value) {
 	if ($feelinglucky && 'later' == $value)
 		$value = 'delete';
 	    switch($value) {
@@ -137,7 +137,7 @@
     <ol id="the-list" class="commentlist">
 <?php
 $i = 0;
-    foreach($comments as $comment) {
+    foreach( (array) $comments as $comment) {
 	++$i;
 	$comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
 	$post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
Index: wp-admin/index.php
===================================================================
--- wp-admin/index.php	(revision 3839)
+++ wp-admin/index.php	(working copy)
@@ -23,7 +23,7 @@
 <ul>
 <?php
 $rss->items = array_slice($rss->items, 0, 10);
-foreach ($rss->items as $item ) {
+foreach ( (array) $rss->items as $item ) {
 ?>
 	<li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
 <?php } ?>
@@ -48,7 +48,7 @@
 <ul>
 <?php 
 if ( $comments ) {
-foreach ($comments as $comment) {
+foreach ( (array) $comments as $comment) {
 	echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
 	edit_comment_link(__("Edit"), ' <small>(', ')</small>'); 
 	echo '</li>';
@@ -66,7 +66,7 @@
 <h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
 <ul>
 <?php
-foreach ($recentposts as $post) {
+foreach ( (array) $recentposts as $post) {
 	if ($post->post_title == '')
 		$post->post_title = sprintf(__('Post #%s'), $post->ID);
 	echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
@@ -85,7 +85,7 @@
 <h3><?php _e('Scheduled Entries:') ?></h3>
 <ul>
 <?php
-foreach ($scheduled as $post) {
+foreach ( (array) $scheduled as $post) {
 	if ($post->post_title == '')
 		$post->post_title = sprintf(__('Post #%s'), $post->ID);
 	echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') ))  . "</li>";
@@ -132,7 +132,7 @@
 <h3><?php _e('WordPress Development Blog'); ?></h3>
 <?php
 $rss->items = array_slice($rss->items, 0, 3);
-foreach ($rss->items as $item ) {
+foreach ( (array) $rss->items as $item ) {
 ?>
 <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
 <p><?php echo $item['description']; ?></p>
@@ -151,7 +151,7 @@
 <ul>
 <?php
 $rss->items = array_slice($rss->items, 0, 20);
-foreach ($rss->items as $item ) {
+foreach ( (array) $rss->items as $item ) {
 ?>
 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
 <?php
Index: wp-admin/admin-db.php
===================================================================
--- wp-admin/admin-db.php	(revision 3839)
+++ wp-admin/admin-db.php	(working copy)
@@ -186,7 +186,7 @@
 	// Only set posts and links to the default category if they're not in another category already.
 	$default_cat = get_option('default_category');
 	$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
-	if ( is_array($posts) ) foreach ($posts as $post_id) {
+	if ( is_array($posts) ) foreach ( (array) $posts as $post_id) {
 		$cats = wp_get_post_cats('', $post_id);
 		if ( 1 == count($cats) )
 			$cats = array($default_cat);
@@ -197,7 +197,7 @@
 
 	$default_link_cat = get_option('default_link_category');
 	$links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
-	if ( is_array($links) ) foreach ($links as $link_id) {
+	if ( is_array($links) ) foreach ( (array) $links as $link_id) {
 		$cats = wp_get_link_cats($link_id);
 		if ( 1 == count($cats) )
 			$cats = array($default_link_cat);
@@ -221,7 +221,7 @@
 
 function wp_create_categories($categories, $post_id = '') {
 	$cat_ids = array ();
-	foreach ($categories as $category) {
+	foreach ( (array) $categories as $category) {
 		if ($id = category_exists($category))
 			$cat_ids[] = $id;
 		else
@@ -253,7 +253,7 @@
 		$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
 
 		if ($post_ids) {
-			foreach ($post_ids as $post_id)
+			foreach ( (array) $post_ids as $post_id)
 				wp_delete_post($post_id);
 		}
 
@@ -384,7 +384,7 @@
 	
 	$categories = wp_get_link_cats($link_id);
 	if( is_array( $categories ) ) {
-		foreach ( $categories as $category ) {
+		foreach ( (array) $categories as $category ) {
 			$wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
 			wp_cache_delete($category, 'category');
 		}
@@ -434,7 +434,7 @@
 	$delete_cats = array_diff($old_categories,$link_categories);
 
 	if ($delete_cats) {
-		foreach ($delete_cats as $del) {
+		foreach ( (array) $delete_cats as $del) {
 			$wpdb->query("
 				DELETE FROM $wpdb->link2cat 
 				WHERE category_id = $del 
@@ -447,7 +447,7 @@
 	$add_cats = array_diff($link_categories, $old_categories);
 
 	if ($add_cats) {
-		foreach ($add_cats as $new_cat) {
+		foreach ( (array) $add_cats as $new_cat) {
 			$wpdb->query("
 				INSERT INTO $wpdb->link2cat (link_id, category_id) 
 				VALUES ($link_ID, $new_cat)");
@@ -456,7 +456,7 @@
 	
 	// Update category counts.
 	$all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
-	foreach ( $all_affected_cats as $cat_id ) {
+	foreach ( (array) $all_affected_cats as $cat_id ) {
 		$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
 		$wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
 		wp_cache_delete($cat_id, 'category');
Index: wp-admin/import/livejournal.php
===================================================================
--- wp-admin/import/livejournal.php	(revision 3839)
+++ wp-admin/import/livejournal.php	(working copy)
@@ -36,7 +36,7 @@
 		$posts = $posts[1];
 		unset($importdata);
 		echo '<ol>';
-		foreach ($posts as $post) {
+		foreach ( (array) $posts as $post) {
 			preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
 			$post_title = $wpdb->escape(trim($post_title[1]));
 			if ( empty($post_title) ) {
@@ -81,7 +81,7 @@
 			if ( $comments ) {
 				$comment_post_ID = $post_id;
 				$num_comments = 0;
-				foreach ($comments as $comment) {
+				foreach ( (array) $comments as $comment) {
 					preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
 					$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
 					$comment_content = $this->unhtmlentities($comment_content);
Index: wp-admin/import/dotclear.php
===================================================================
--- wp-admin/import/dotclear.php	(revision 3839)
+++ wp-admin/import/dotclear.php	(working copy)
@@ -221,7 +221,7 @@
 		if(is_array($categories))
 		{
 			echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
-			foreach ($categories as $category) 
+			foreach ( (array) $categories as $category) 
 			{
 				$count++;
 				extract($category);
@@ -262,7 +262,7 @@
 		if(is_array($users))
 		{
 			echo '<p>'.__('Importing Users...').'<br /><br /></p>';
-			foreach($users as $user)
+			foreach( (array) $users as $user)
 			{
 				$count++;
 				extract($user);
@@ -312,7 +312,7 @@
 				update_usermeta( $ret_id, 'rich_editing', 'false');
 				update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
 				update_usermeta( $ret_id, 'last_name', csc ($user_nom));
-			}// End foreach($users as $user)
+			}// End foreach( (array) $users as $user)
 
 			// Store id translation array for future use
 			add_option('dcid2wpid',$dcid2wpid);
@@ -339,7 +339,7 @@
 		if(is_array($posts))
 		{
 			echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
-			foreach($posts as $post)
+			foreach( (array) $posts as $post)
 			{
 				$count++;
 				extract($post);
@@ -430,7 +430,7 @@
 		if(is_array($comments))
 		{
 			echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
-			foreach($comments as $comment)
+			foreach( (array) $comments as $comment)
 			{
 				$count++;
 				extract($comment);
@@ -501,7 +501,7 @@
 		if(is_array($links))
 		{
 			echo '<p>'.__('Importing Links...').'<br /><br /></p>';
-			foreach($links as $link)
+			foreach( (array) $links as $link)
 			{
 				$count++;
 				extract($link);
Index: wp-admin/import/mt.php
===================================================================
--- wp-admin/import/mt.php	(revision 3839)
+++ wp-admin/import/mt.php	(working copy)
@@ -36,7 +36,7 @@
 	<?php
 
 
-		foreach ($users as $user) {
+		foreach ( (array) $users as $user) {
 			echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
 		}
 ?>
@@ -85,7 +85,7 @@
 	function get_mt_authors() {
 		$temp = array ();
 		$i = -1;
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 			if ('' != trim($post)) {
 				++ $i;
 				preg_match("|AUTHOR:(.*)|", $post, $thematch);
@@ -110,14 +110,14 @@
 		$formnames = array ();
 		$selectnames = array ();
 
-		foreach ($_POST['user'] as $key => $line) {
+		foreach ( (array) $_POST['user'] as $key => $line) {
 			$newname = trim(stripslashes($line));
 			if ($newname == '')
 				$newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
 			array_push($formnames, "$newname");
 		} // $formnames is the array with the form entered names
 
-		foreach ($_POST['userselect'] as $user => $key) {
+		foreach ( (array) $_POST['userselect'] as $user => $key) {
 			$selected = trim(stripslashes($key));
 			array_push($selectnames, "$selected");
 		}
@@ -146,7 +146,7 @@
 		echo '<ol id="authors">';
 		echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
 		$j = -1;
-		foreach ($authors as $author) {
+		foreach ( (array) $authors as $author) {
 			++ $j;
 			echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing ';
 			$this->users_form($j);
@@ -179,7 +179,7 @@
 		global $wpdb;
 		$i = -1;
 		echo "<div class='wrap'><ol>";
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 			if ('' != trim($post)) {
 				++ $i;
 				unset ($post_categories);
@@ -215,7 +215,7 @@
 
 				// Grab the metadata from what's left
 				$metadata = explode("\n", $post);
-				foreach ($metadata as $line) {
+				foreach ( (array) $metadata as $line) {
 					preg_match("/^(.*?):(.*)/", $line, $token);
 					$key = trim($token[1]);
 					$value = trim($token[2]);
@@ -299,7 +299,7 @@
 				// Now for comments
 				$comments = explode("-----\nCOMMENT:", $comments[0]);
 				$num_comments = 0;
-				foreach ($comments as $comment) {
+				foreach ( (array) $comments as $comment) {
 					if ('' != trim($comment)) {
 						// Author
 						preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
@@ -341,7 +341,7 @@
 				$pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
 				$pings = explode("-----\nPING:", $pings[0]);
 				$num_pings = 0;
-				foreach ($pings as $ping) {
+				foreach ( (array) $pings as $ping) {
 					if ('' != trim($ping)) {
 						// 'Author'
 						preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
Index: wp-admin/import/blogger.php
===================================================================
--- wp-admin/import/blogger.php	(revision 3839)
+++ wp-admin/import/blogger.php	(working copy)
@@ -49,14 +49,14 @@
 
 		// put the rest of the headers in an array
 		$response_header_array = array();
-		foreach($response_header_lines as $header_line) {
+		foreach( (array) $response_header_lines as $header_line) {
 			list($header,$value) = explode(': ', $header_line, 2);
 			$response_header_array[$header] .= $value."\n";
 		}
 
 		$cookie_array = array();
 		$cookies = explode("\n", $response_header_array["Set-Cookie"]);
-		foreach($cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
+		foreach( (array) $cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
 
 		return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body);
 	}
@@ -118,7 +118,7 @@
 	function post_blogger($url, $header = false, $paramary = false, $parse=true) {
 		$params = '';
 		if ( is_array($paramary) ) {
-			foreach($paramary as $key=>$value)
+			foreach( (array) $paramary as $key=>$value)
 				if($key && $value != '')
 					$params.=$key."=".urlencode(stripslashes($value))."&";
 		}
@@ -149,7 +149,7 @@
 	function show_blogs() {
 		global $import;
 		echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>";
-		foreach ( $this->import['blogs'] as $blog ) {
+		foreach ( (array) $this->import['blogs'] as $blog ) {
 			if (9 == $blog['nextstep']) $status = "100%";
 			elseif (8 == $blog['nextstep']) $status = "90%";
 			elseif (7 == $blog['nextstep']) $status = "82.5%";
@@ -244,7 +244,7 @@
 				die(__('No blogs found for this user.'));
 			$this->import['blogs'] = array();
 			$template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>';
-			foreach ( $blogsary[1] as $key => $id ) {
+			foreach ( (array) $blogsary[1] as $key => $id ) {
 				// Define the required Blogger options.
 				$blog_opts = array(
 					'blog-options-basic' => false,
@@ -256,7 +256,7 @@
 				);
 
 				// Build the blog options array template
-				foreach ($blog_opts as $blog_opt => $modify)
+				foreach ( (array) $blog_opts as $blog_opt => $modify)
 					$new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false);
 
 				$this->import['blogs']["$id"] = array(
@@ -292,7 +292,7 @@
 	function backup_settings() {
 		$output.= '<h1>'.__('Backing up Blogger options')."</h1>\n";
 		$form = false;
-		foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {
+		foreach ( (array) $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {
 			if ( $blog_opt == $_GET['form'] ) {
 				// Save the posted form data
 				$this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST;
@@ -366,7 +366,7 @@
 		if (! strstr($bloghtml['body'], '<a class="archive"') )
 			die(__('Your Blogger blog did not take the new template or did not respond.'));
 		preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);
-		foreach ($archives[1] as $archive) {
+		foreach ( (array) $archives[1] as $archive) {
 			$this->import['blogs'][$_GET['blog']]['archives'][$archive] = false;
 		}
 		$this->set_next_step(6);
@@ -379,7 +379,7 @@
 		$output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';
 		$did_one = false;
 		$post_array = $posts = array();
-		foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
+		foreach ( (array) $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
 			$archivename = substr(basename($url),0,7);
 			if ( $status || $did_one ) {
 				$foo = 'bar';
@@ -497,11 +497,11 @@
 				}
 				if ( count($post_array) ) {
 					krsort($post_array);
-					foreach($post_array as $post) {
+					foreach( (array) $post_array as $post) {
 						if ( ! $comment_post_ID = $post['ID'] )
 							$comment_post_ID = wp_insert_post($post['post']);
 						if ( $post['comments'] ) {
-							foreach ( $post['comments'] as $comment ) {
+							foreach ( (array) $post['comments'] as $comment ) {
 								$comment['comment_post_ID'] = $comment_post_ID;
 								wp_insert_comment($comment);
 							}
@@ -533,7 +533,7 @@
 			$this->import['reversed'] = true;
 			update_option('import-blogger', $this->import);
 		}
-		foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {
+		foreach ( (array) $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {
 			if ( $did_one ) {
 				$output .= "<p>$blog_opt</p>\n";
 			} elseif ( $optary['restored'] || ! $optary['modify'] ) {
Index: wp-admin/import/textpattern.php
===================================================================
--- wp-admin/import/textpattern.php	(revision 3839)
+++ wp-admin/import/textpattern.php	(working copy)
@@ -163,7 +163,7 @@
 		if(is_array($categories))
 		{
 			echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
-			foreach ($categories as $category) 
+			foreach ( (array) $categories as $category) 
 			{
 				$count++;
 				extract($category);
@@ -204,7 +204,7 @@
 		if(is_array($users))
 		{
 			echo '<p>'.__('Importing Users...').'<br /><br /></p>';
-			foreach($users as $user)
+			foreach( (array) $users as $user)
 			{
 				$count++;
 				extract($user);
@@ -252,7 +252,7 @@
 
 				update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
 				update_usermeta( $ret_id, 'rich_editing', 'false');
-			}// End foreach($users as $user)
+			}// End foreach( (array) $users as $user)
 
 			// Store id translation array for future use
 			add_option('txpid2wpid',$txpid2wpid);
@@ -279,7 +279,7 @@
 		if(is_array($posts))
 		{
 			echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
-			foreach($posts as $post)
+			foreach( (array) $posts as $post)
 			{
 				$count++;
 				extract($post);
@@ -360,7 +360,7 @@
 		if(is_array($comments))
 		{
 			echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
-			foreach($comments as $comment)
+			foreach( (array) $comments as $comment)
 			{
 				$count++;
 				extract($comment);
@@ -428,7 +428,7 @@
 		if(is_array($links))
 		{
 			echo '<p>'.__('Importing Links...').'<br /><br /></p>';
-			foreach($links as $link)
+			foreach( (array) $links as $link)
 			{
 				$count++;
 				extract($link);
Index: wp-admin/import/blogware.php
===================================================================
--- wp-admin/import/blogware.php	(revision 3839)
+++ wp-admin/import/blogware.php	(working copy)
@@ -38,7 +38,7 @@
 		$posts = $posts[1];
 		unset($importdata);
 		echo '<ol>';		
-		foreach ($posts as $post) {
+		foreach ( (array) $posts as $post) {
 			flush();
 			preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
 			$post_type = $post_type[1];
@@ -57,7 +57,7 @@
 			$categories = $categories[1];
 
 			$cat_index = 0;
-			foreach ($categories as $category) {
+			foreach ( (array) $categories as $category) {
 				$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
 				$cat_index++;
 			}
@@ -104,7 +104,7 @@
 			if ( $comments ) {
 				$comment_post_ID = $post_id;
 				$num_comments = 0;
-				foreach ($comments as $comment) {
+				foreach ( (array) $comments as $comment) {
 					preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
 					$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
 					$comment_content = $this->unhtmlentities($comment_content);
Index: wp-admin/import/greymatter.php
===================================================================
--- wp-admin/import/greymatter.php	(revision 3839)
+++ wp-admin/import/greymatter.php	(working copy)
@@ -101,7 +101,7 @@
 	chdir($gmpath);
 	$userbase = file("gm-authors.cgi");
 
-	foreach($userbase as $user) {
+	foreach( (array) $userbase as $user) {
 		$userdata=explode("|", $user);
 
 		$user_ip="127.0.0.1";
Index: wp-admin/import/rss.php
===================================================================
--- wp-admin/import/rss.php	(revision 3839)
+++ wp-admin/import/rss.php	(working copy)
@@ -36,7 +36,7 @@
 		preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
 		$this->posts = $this->posts[1];
 		$index = 0;
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 			preg_match('|<title>(.*?)</title>|is', $post, $post_title);
 			$post_title = $wpdb->escape(trim($post_title[1]));
 
@@ -63,7 +63,7 @@
 			}
 
 			$cat_index = 0;
-			foreach ($categories as $category) {
+			foreach ( (array) $categories as $category) {
 				$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
 				$cat_index++;
 			}
@@ -98,7 +98,7 @@
 	function import_posts() {
 		echo '<ol>';
 
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 			echo "<li>".__('Importing post...');
 
 			extract($post);
Index: wp-admin/import/wordpress.php
===================================================================
--- wp-admin/import/wordpress.php	(revision 3839)
+++ wp-admin/import/wordpress.php	(working copy)
@@ -41,7 +41,7 @@
 ?><select name="userselect[<?php echo $n; ?>]">
 	<option value="#NONE#">- Select -</option>
 	<?php
-		foreach ($users as $user) {
+		foreach ( (array) $users as $user) {
 			echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
 		}
 ?>
@@ -88,7 +88,7 @@
 	function get_wp_authors() {
 		$temp = array ();
 		$i = -1;
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 			if ('' != trim($post)) {
 				++ $i;
 				$author = $this->get_tag( $post, 'dc:creator' );
@@ -112,14 +112,14 @@
 		$formnames = array ();
 		$selectnames = array ();
 
-		foreach ($_POST['user'] as $key => $line) {
+		foreach ( (array) $_POST['user'] as $key => $line) {
 			$newname = trim(stripslashes($line));
 			if ($newname == '')
 				$newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
 			array_push($formnames, "$newname");
 		} // $formnames is the array with the form entered names
 
-		foreach ($_POST['userselect'] as $user => $key) {
+		foreach ( (array) $_POST['userselect'] as $user => $key) {
 			$selected = trim(stripslashes($key));
 			array_push($selectnames, "$selected");
 		}
@@ -146,7 +146,7 @@
 		echo '<ol id="authors">';
 		echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
 		$j = -1;
-		foreach ($authors as $author) {
+		foreach ( (array) $authors as $author) {
 			++ $j;
 			echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing ';
 			$this->users_form($j);
@@ -179,7 +179,7 @@
 		global $wpdb;
 		$i = -1;
 		echo '<ol>';
-		foreach ($this->posts as $post) {
+		foreach ( (array) $this->posts as $post) {
 
 			// There are only ever one of these
 			$post_title     = $this->get_tag( $post, 'title' );
@@ -203,7 +203,7 @@
 			$categories = $categories[1];
 
 			$cat_index = 0;
-			foreach ($categories as $category) {
+			foreach ( (array) $categories as $category) {
 				$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
 				$cat_index++;
 			}
@@ -229,7 +229,7 @@
 				preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
 				$comments = $comments[1];
 				$num_comments = 0;
-				if ( $comments) { foreach ($comments as $comment) {
+				if ( $comments) { foreach ( (array) $comments as $comment) {
 					$comment_author       = $this->get_tag( $comment, 'wp:comment_author');
 					$comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
 					$comment_author_IP    = $this->get_tag( $comment, 'wp:comment_author_IP');
@@ -253,7 +253,7 @@
 				// Now for post meta
 				preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
 				$postmeta = $postmeta[1];
-				if ( $postmeta) { foreach ($postmeta as $p) {
+				if ( $postmeta) { foreach ( (array) $postmeta as $p) {
 					$key   = $this->get_tag( $p, 'wp:meta_key' );
 					$value = $this->get_tag( $p, 'wp:meta_value' );
 					add_post_meta( $post_id, $key, $value );
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(revision 3839)
+++ wp-admin/edit-form-advanced.php	(working copy)
@@ -38,7 +38,7 @@
 if ('' != $post->pinged) {
 	$pings = '<p>'. __('Already pinged:') . '</p><ul>';
 	$already_pinged = explode("\n", trim($post->pinged));
-	foreach ($already_pinged as $pinged_url) {
+	foreach ( (array) $already_pinged as $pinged_url) {
 		$pings .= "\n\t<li>$pinged_url</li>";
 	}
 	$pings .= '</ul>';
@@ -120,7 +120,7 @@
 <div class="dbx-content">
 <select name="post_author_override" id="post_author_override">
 <?php 
-foreach ($authors as $o) :
+foreach ( (array) $authors as $o) :
 $o = get_userdata( $o->ID );
 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
 else $selected = '';
Index: wp-admin/menu.php
===================================================================
--- wp-admin/menu.php	(revision 3839)
+++ wp-admin/menu.php	(working copy)
@@ -52,15 +52,15 @@
 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
 
 // Create list of page plugin hook names.
-foreach ($menu as $menu_page) {
+foreach ( (array) $menu as $menu_page) {
 	$admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
 }
 
 do_action('admin_menu', '');
 
 // Loop over submenus and remove pages for which the user does not have privs.
-foreach ($submenu as $parent => $sub) {
-	foreach ($sub as $index => $data) {
+foreach ( (array) $submenu as $parent => $sub) {
+	foreach ( (array) $sub as $index => $data) {
 		if ( ! current_user_can($data[1]) ) {
 			$menu_nopriv[$data[2]] = true;
 			unset($submenu[$parent][$index]);
@@ -75,7 +75,7 @@
 // Remove menus that have no accessible submenus and require privs that the user does not have.
 // Menus for which the original parent is not acessible due to lack of privs will have the next
 // submenu in line be assigned as the new menu parent. 
-foreach ( $menu as $id => $data ) {
+foreach ( (array) $menu as $id => $data ) {
 	// If submenu is empty...
 	if ( empty($submenu[$data[2]]) ) {
 		// And user doesn't have privs, remove menu.
@@ -94,7 +94,7 @@
 			$real_parent_file[$old_parent] = $new_parent;
 			$menu[$id][2] = $new_parent;
 			
-			foreach ($submenu[$old_parent] as $index => $data) {
+			foreach ( (array) $submenu[$old_parent] as $index => $data) {
 				$submenu[$new_parent][$index] = $submenu[$old_parent][$index];
 				unset($submenu[$old_parent][$index]);
 			}
Index: wp-admin/link-import.php
===================================================================
--- wp-admin/link-import.php	(revision 3839)
+++ wp-admin/link-import.php	(working copy)
@@ -47,7 +47,7 @@
 <?php _e('Category:') ?> <select name="cat_id">
 <?php
 $categories = get_categories('hide_empty=0');
-foreach ($categories as $category) {
+foreach ( (array) $categories as $category) {
 ?>
 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
 <?php
Index: wp-admin/plugins.php
===================================================================
--- wp-admin/plugins.php	(revision 3839)
+++ wp-admin/plugins.php	(working copy)
@@ -41,7 +41,7 @@
 
 // If a plugin file does not exist, remove it from the list of active
 // plugins.
-foreach ($check_plugins as $check_plugin) {
+foreach ( (array) $check_plugins as $check_plugin) {
 	if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
 			$current = get_settings('active_plugins');
 			$key = array_search($check_plugin, $current);
@@ -96,7 +96,7 @@
 
 	uksort($plugins, 'sort_plugins');
 
-	foreach($plugins as $plugin_file => $plugin_data) {
+	foreach( (array) $plugins as $plugin_file => $plugin_data) {
 		$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
 
 		if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
Index: wp-admin/edit.php
===================================================================
--- wp-admin/edit.php	(revision 3839)
+++ wp-admin/edit.php	(working copy)
@@ -18,7 +18,7 @@
     <p><strong><?php _e('Your Drafts:') ?></strong> 
     <?php
 	$i = 0;
-	foreach ($drafts as $draft) {
+	foreach ( (array) $drafts as $draft) {
 		if (0 != $i)
 			echo ', ';
 		$draft->post_title = stripslashes($draft->post_title);
@@ -35,7 +35,7 @@
     <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong> 
     <?php
 	$i = 0;
-	foreach ($other_drafts as $draft) {
+	foreach ( (array) $other_drafts as $draft) {
 		if (0 != $i)
 			echo ', ';
 		$draft->post_title = stripslashes($draft->post_title);
@@ -90,7 +90,7 @@
 	<legend><?php _e('Browse Month&hellip;') ?></legend>
     <select name='m'>
 	<?php
-		foreach ($arc_result as $arc_row) {
+		foreach ( (array) $arc_result as $arc_row) {
 			if ( $arc_row->yyear == 0 )
 				continue;
 			$arc_row->mmonth = zeroise($arc_row->mmonth, 2);
@@ -137,7 +137,7 @@
 	<thead>
 	<tr>
 
-<?php foreach($posts_columns as $column_display_name) { ?>
+<?php foreach( (array) $posts_columns as $column_display_name) { ?>
 	<th scope="col"><?php echo $column_display_name; ?></th>
 <?php } ?>
 
@@ -147,7 +147,7 @@
 <?php
 if ($posts) {
 $bgcolor = '';
-foreach ($posts as $post) { start_wp();
+foreach ( (array) $posts as $post) { start_wp();
 add_filter('the_title','wp_specialchars');
 $class = ('alternate' == $class) ? '' : 'alternate';
 ?> 
@@ -155,7 +155,7 @@
 
 <?php
 
-foreach($posts_columns as $column_name=>$column_display_name) {
+foreach( (array) $posts_columns as $column_name=>$column_display_name) {
 
 	switch($column_name) {
 
@@ -254,7 +254,7 @@
 <ol id="the-list" class="commentlist"> 
 <?php
 $i = 0;
-foreach ($comments as $comment) {
+foreach ( (array) $comments as $comment) {
 
 		++$i; $class = '';
 		$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
Index: wp-admin/options.php
===================================================================
--- wp-admin/options.php	(revision 3839)
+++ wp-admin/options.php	(working copy)
@@ -32,7 +32,7 @@
 	check_admin_referer('update-options');
 
 	if (!$_POST['page_options']) {
-		foreach ($_POST as $key => $value) {
+		foreach ( (array) $_POST as $key => $value) {
 			$options[] = $key;
 		}
 	} else {
@@ -47,7 +47,7 @@
 	// Options that if not there have 0 value but need to be something like "closed"
 	$nonbools = array('default_ping_status', 'default_comment_status');
 	if ($options) {
-		foreach ($options as $option) {
+		foreach ( (array) $options as $option) {
 			$option = trim($option);
 			$value = trim(stripslashes($_POST[$option]));
 				if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
@@ -95,7 +95,7 @@
 <?php
 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
 
-foreach ($options as $option) :
+foreach ( (array) $options as $option) :
 	$value = wp_specialchars($option->option_value, 'single');
 	echo "
 <tr>
Index: wp-admin/link.php
===================================================================
--- wp-admin/link.php	(revision 3839)
+++ wp-admin/link.php	(working copy)
@@ -42,7 +42,7 @@
 		}
 
 		$deleted = 0;
-		foreach ($linkcheck as $link_id) {
+		foreach ( (array) $linkcheck as $link_id) {
 			$link_id = (int) $link_id;
 			
 			if ( wp_delete_link($link_id) )
Index: wp-admin/profile.php
===================================================================
--- wp-admin/profile.php	(revision 3839)
+++ wp-admin/profile.php	(working copy)
@@ -122,7 +122,7 @@
       <th scope="row"><?php _e('Additional Capabilities:') ?></th>
       <td><?php 
 			$output = '';
-			foreach($profileuser->caps as $cap => $value) {
+			foreach( (array) $profileuser->caps as $cap => $value) {
 				if(!$wp_roles->is_role($cap)) {
 					if($output != '') $output .= ', ';
 					$output .= $value ? $cap : "Denied: {$cap}";
Index: wp-admin/user-edit.php
===================================================================
--- wp-admin/user-edit.php	(revision 3839)
+++ wp-admin/user-edit.php	(working copy)
@@ -63,7 +63,7 @@
 <div class="error">
 	<ul>
 	<?php
-	foreach( $errors->get_error_messages() as $message )
+	foreach( (array) $errors->get_error_messages() as $message )
 		echo "<li>$message</li>";
 	?>
 	</ul>
@@ -90,7 +90,7 @@
 <?php
 // print_r($profileuser);
 echo '<select name="role">';
-foreach($wp_roles->role_names as $role => $name) {
+foreach( (array) $wp_roles->role_names as $role => $name) {
 	$selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : '';
 	echo "<option value=\"{$role}\"{$selected}>{$name}</option>";
 }
@@ -180,7 +180,7 @@
       <th scope="row"><?php _e('Additional Capabilities:') ?></th>
       <td><?php 
 			$output = '';
-			foreach($profileuser->caps as $cap => $value) {
+			foreach( (array) $profileuser->caps as $cap => $value) {
 				if(!$wp_roles->is_role($cap)) {
 					if($output != '') $output .= ', ';
 					$output .= $value ? $cap : "Denied: {$cap}";
Index: wp-admin/setup-config.php
===================================================================
--- wp-admin/setup-config.php	(revision 3839)
+++ wp-admin/setup-config.php	(working copy)
@@ -154,7 +154,7 @@
     require_once('../wp-includes/wp-db.php');
 	$handle = fopen('../wp-config.php', 'w');
 
-    foreach ($configFile as $line_num => $line) {
+    foreach ( (array) $configFile as $line_num => $line) {
         switch (substr($line,0,16)) {
             case "define('DB_NAME'":
                 fwrite($handle, str_replace("wordpress", $dbname, $line));
Index: wp-admin/link-manager.php
===================================================================
--- wp-admin/link-manager.php	(revision 3839)
+++ wp-admin/link-manager.php	(working copy)
@@ -95,7 +95,7 @@
 <?php $categories = get_categories("hide_empty=1&type=link"); ?>
 <select name="cat_id">
 <option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
-<?php foreach ($categories as $cat): ?>
+<?php foreach ( (array) $categories as $cat): ?>
 <option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
 </option>
 <?php endforeach; ?>
@@ -133,7 +133,7 @@
 	$cat_id = '';
 $links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
 if ($links)
-	foreach ($links as $link) {
+	foreach ( (array) $links as $link) {
 		$link->link_name = wp_specialchars($link->link_name);
 		$link->link_description = wp_specialchars($link->link_description);
 		$link->link_url = wp_specialchars($link->link_url);
@@ -161,7 +161,7 @@
         <?php
 
 		$cat_names = array();
-		foreach ($link->link_category as $category) {
+		foreach ( (array) $link->link_category as $category) {
 			$cat_name = get_the_category_by_ID($category);
 			$cat_name = wp_specialchars($cat_name);
 			if ( $cat_id != $category )
Index: wp-admin/import.php
===================================================================
--- wp-admin/import.php	(revision 3839)
+++ wp-admin/import.php	(working copy)
@@ -34,7 +34,7 @@
 
 <?php
 	$style = '';
-	foreach ($importers as $id => $data) {
+	foreach ( (array) $importers as $id => $data) {
 		$style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
 		$action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
 
Index: wp-admin/options-writing.php
===================================================================
--- wp-admin/options-writing.php	(revision 3839)
+++ wp-admin/options-writing.php	(working copy)
@@ -34,7 +34,7 @@
 <td><select name="default_category" id="default_category">
 <?php
 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
-foreach ($categories as $category) :
+foreach ( (array) $categories as $category) :
 if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
 else $selected = '';
 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
@@ -46,7 +46,7 @@
 <th scope="row"><?php _e('Default bookmark category:') ?></th>
 <td><select name="default_link_category" id="default_link_category">
 <?php
-foreach ($categories as $category) :
+foreach ( (array) $categories as $category) :
 if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
 else $selected = '';
 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
@@ -83,7 +83,7 @@
 <td><select name="default_email_category" id="default_email_category">
 <?php
 //Alreay have $categories from default_category
-foreach ($categories as $category) :
+foreach ( (array) $categories as $category) :
 if ($category->cat_ID == get_settings('default_email_category')) $selected = " selected='selected'";
 else $selected = '';
 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
Index: wp-admin/export.php
===================================================================
--- wp-admin/export.php	(revision 3839)
+++ wp-admin/export.php	(working copy)
@@ -48,7 +48,7 @@
 	<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
 	<language><?php echo get_option('rss_language'); ?></language>
 	<?php do_action('rss2_head'); ?>
-	<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+	<?php if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
 <item>
 <title><?php the_title_rss() ?></title>
 <link><?php permalink_single_rss() ?></link>
@@ -71,7 +71,7 @@
 $postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); 
 if ( $postmeta ) {
 ?>
-<?php foreach( $postmeta as $meta ) { ?>
+<?php foreach( (array) $postmeta as $meta ) { ?>
 <wp:postmeta>
 <wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
 <wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
@@ -80,7 +80,7 @@
 <?php } ?>
 <?php
 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); 
-if ( $comments ) { foreach ( $comments as $c ) { ?>
+if ( $comments ) { foreach ( (array) $comments as $c ) { ?>
 <wp:comment>
 <wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
 <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
Index: wp-admin/plugin-editor.php
===================================================================
--- wp-admin/plugin-editor.php	(revision 3839)
+++ wp-admin/plugin-editor.php	(working copy)
@@ -89,7 +89,7 @@
 if ($plugin_files) :
 ?>
   <ul>
-<?php foreach($plugin_files as $plugin_file) : ?>
+<?php foreach( (array) $plugin_files as $plugin_file) : ?>
 		 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
 <?php endforeach; ?>
   </ul>
Index: wp-admin/upgrade-schema.php
===================================================================
--- wp-admin/upgrade-schema.php	(revision 3839)
+++ wp-admin/upgrade-schema.php	(working copy)
@@ -235,13 +235,13 @@
 
 	// Delete unused options
 	$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
-	foreach ($unusedoptions as $option) :
+	foreach ( (array) $unusedoptions as $option) :
 		delete_option($option);
 	endforeach;
 
 	// Set up a few options not to load by default
 	$fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
-	foreach ($fatoptions as $fatoption) :
+	foreach ( (array) $fatoptions as $fatoption) :
 		$wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
 	endforeach;
 }
@@ -342,7 +342,7 @@
 
 function populate_roles_210() {
 	$roles = array('administrator', 'editor');
-	foreach ($roles as $role) {
+	foreach ( (array) $roles as $role) {
 		$role = get_role($role);
 		if ( empty($role) )
 			continue;
Index: wp-admin/themes.php
===================================================================
--- wp-admin/themes.php	(revision 3839)
+++ wp-admin/themes.php	(working copy)
@@ -58,7 +58,7 @@
 $theme_names = array_keys($themes);
 natcasesort($theme_names);
 
-foreach ($theme_names as $theme_name) {
+foreach ( (array) $theme_names as $theme_name) {
 	if ( $theme_name == $ct->name )
 		continue;
 	$template = $themes[$theme_name]['Template'];
@@ -106,7 +106,7 @@
 	$theme_names = array_keys($broken_themes);
 	natcasesort($theme_names);
 
-	foreach ($theme_names as $theme_name) {
+	foreach ( (array) $theme_names as $theme_name) {
 		$title = $broken_themes[$theme_name]['Title'];
 		$description = $broken_themes[$theme_name]['Description'];
 
