Index: wp-admin/includes/plugin.php
===================================================================
--- wp-admin/includes/plugin.php	(revision 12605)
+++ wp-admin/includes/plugin.php	(working copy)
@@ -258,8 +258,8 @@
  * @param string $plugin Base plugin path from plugins directory.
  * @return bool True, if in the active plugins list. False, not in the list.
  */
-function is_plugin_active($plugin) {
-	return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
+function is_plugin_active( $plugin ) {
+	return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) );
 }
 
 /**
@@ -286,9 +286,9 @@
  * @param string $redirect Optional. URL to redirect to.
  * @return WP_Error|null WP_Error on invalid file or null on success.
  */
-function activate_plugin($plugin, $redirect = '') {
-	$current = get_option('active_plugins');
-	$plugin = plugin_basename(trim($plugin));
+function activate_plugin( $plugin, $redirect = '' ) {
+	$current = get_option( 'active_plugins', array() );
+	$plugin  = plugin_basename( trim( $plugin ) );
 
 	$valid = validate_plugin($plugin);
 	if ( is_wp_error($valid) )
@@ -322,13 +322,10 @@
  * @param string|array $plugins Single plugin or list of plugins to deactivate.
  * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
  */
-function deactivate_plugins($plugins, $silent= false) {
-	$current = get_option('active_plugins');
+function deactivate_plugins( $plugins, $silent = false ) {
+	$current = get_option( 'active_plugins', array() );
 
-	if ( !is_array($plugins) )
-		$plugins = array($plugins);
-
-	foreach ( $plugins as $plugin ) {
+	foreach ( (array) $plugins as $plugin ) {
 		$plugin = plugin_basename($plugin);
 		if( ! is_plugin_active($plugin) )
 			continue;
@@ -475,26 +472,32 @@
 	return true;
 }
 
+/**
+ * validate active plugins
+ * 
+ * validate all active plugins, deactivates invalid and 
+ * returns an array of deactived ones.
+ * 
+ * @since unknown
+ * @return array invalid plugins, plugin as key, error as value
+ */
 function validate_active_plugins() {
-	$check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') );
+	$plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
 
-	// Sanity check.  If the active plugin list is not an array, make it an
-	// empty array.
-	if ( !is_array($check_plugins) ) {
+	// validate vartype: array
+	if ( !is_array( $plugins ) ) {
 		update_option('active_plugins', array());
 		return;
 	}
 
-	//Invalid is any plugin that is deactivated due to error.
 	$invalid = array();
 
-	// If a plugin file does not exist, remove it from the list of active
-	// plugins.
-	foreach ( $check_plugins as $check_plugin ) {
-		$result = validate_plugin($check_plugin);
+	// invalid plugins get deactivated
+	foreach ( $plugins as $plugin ) {
+		$result = validate_plugin( $plugin );
 		if ( is_wp_error( $result ) ) {
-			$invalid[$check_plugin] = $result;
-			deactivate_plugins( $check_plugin, true);
+			$invalid[$plugin] = $result;
+			deactivate_plugins( $plugin, true );
 		}
 	}
 	return $invalid;
Index: wp-admin/plugin-editor.php
===================================================================
--- wp-admin/plugin-editor.php	(revision 12605)
+++ wp-admin/plugin-editor.php	(working copy)
@@ -208,7 +208,7 @@
 		<div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
 		<?php endif; ?>
 <?php if ( is_writeable($real_file) ) : ?>
-	<?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
+	<?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?>
 		<p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended.  If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
 	<?php } ?>
 	<p class="submit">
Index: wp-includes/plugin.php
===================================================================
--- wp-includes/plugin.php	(revision 12605)
+++ wp-includes/plugin.php	(working copy)
@@ -707,4 +707,59 @@
 	}
 }
 
-?>
+
+/**
+ * valid plugins
+ * 
+ * filter a/the active list of plugins to filenames that are valid to
+ * include.
+ * 
+ * Examples:
+ * 
+ *    valid_plugins(); 
+ *    return array of standard plugin files to include
+ *    
+ *    valid_plugins( WPMU_PLUGIN_DIR )
+ *    return array of WPMU plugin files to include
+ * 
+ * @param array|string $plugins (optional) list of plugins, will take 
+ *                              active_plugins option as default. 
+ *                              additionally the path of a directory can 
+ *                              be passed as string which will be iterated 
+ *                              for valid plugin files then (WPMU Plugins 
+ *                              flat style).
+ * @param string $dir (optional) plugin directory, defaults to WP_PLUGIN_DIR or
+ *                              to $plugins if used as string.
+ * @return array list of plugin files (full, absolute path) ripe to be included
+ * @since 3.0
+ */
+function valid_plugins( $plugins = null, $dir = null ) {
+
+	if ( is_null( $plugins ) )
+		$plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
+		
+	if ( is_string( $plugins ) && is_dir( $plugins ) && $dh = opendir( $plugins ) ) {
+		$dir = is_null( $dir ) ? $plugins : $dir;
+		$plugins = array();
+		while ( ( $plugins[] = readdir( $dh ) ) !== false );
+	}
+	
+	if ( !is_array( $plugins ) )
+		return array();
+		
+	if ( is_null( $dir ) )
+		$dir = WP_PLUGIN_DIR;
+		
+	// check the $plugin name/filename
+	$valid = array();
+	foreach( $plugins as $plugin ) {
+		if ( validate_file( $plugin ) // $plugin must validate as file
+			|| '.php' != substr( $plugin, -4 ) // $plugin must end with '.php'
+			|| !file_exists( $path = $dir . '/' . $plugin ) // $plugin must exist
+			) continue;
+		$valid[] = $path; 
+	}
+	return $valid;
+}
+
+?>
\ No newline at end of file
Index: wp-includes/update.php
===================================================================
--- wp-includes/update.php	(revision 12605)
+++ wp-includes/update.php	(working copy)
@@ -112,7 +112,7 @@
 		require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
 	$plugins = get_plugins();
-	$active  = get_option( 'active_plugins' );
+	$active  = get_option( 'active_plugins', array() );
 	$current = get_transient( 'update_plugins' );
 	if ( ! is_object($current) )
 		$current = new stdClass;
@@ -147,7 +147,7 @@
 	$current->last_checked = time();
 	set_transient( 'update_plugins', $current );
 
-	$to_send = (object)compact('plugins', 'active');
+	$to_send = (object) compact('plugins', 'active');
 
 	$options = array(
 		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
Index: wp-settings.php
===================================================================
--- wp-settings.php	(revision 12605)
+++ wp-settings.php	(working copy)
@@ -439,15 +439,8 @@
 if ( !defined( 'MUPLUGINDIR' ) )
 	define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH.  For back compat.
 
-if ( is_dir( WPMU_PLUGIN_DIR ) ) {
-	if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
-		while ( ( $plugin = readdir( $dh ) ) !== false ) {
-			if ( substr( $plugin, -4 ) == '.php' ) {
-				include_once( WPMU_PLUGIN_DIR . '/' . $plugin );
-			}
-		}
-	}
-}
+foreach ( valid_plugins( WPMU_PLUGIN_DIR ) as $plugin )
+	include_once( $plugin );	
 do_action('muplugins_loaded');
 
 /**
@@ -581,22 +574,12 @@
 		require(ABSPATH . 'my-hacks.php');
 }
 
-$current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
-if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
-	foreach ( $current_plugins as $plugin ) {
-		// check the $plugin filename
-		// Validate plugin filename
-		if ( validate_file($plugin) // $plugin must validate as file
-			|| '.php' != substr($plugin, -4) // $plugin must end with '.php'
-			|| !file_exists(WP_PLUGIN_DIR . '/' . $plugin)	// $plugin must exist
-			)
-			continue;
-
-		include_once(WP_PLUGIN_DIR . '/' . $plugin);
-	}
+// include valid plugin files / load plugins into global namespace
+if ( !defined('WP_INSTALLING') ) {
+	foreach ( valid_plugins() as $plugin )
+		include_once($plugin);
 	unset($plugin);
 }
-unset($current_plugins);
 
 require (ABSPATH . WPINC . '/pluggable.php');
 
