]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-upgrader.php
WordPress 3.7.2
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-upgrader.php
index 90b9658d573f4d81bcb3586707d2f3e843c49082..330f5ea0550d7b98fe52ddddfddfc9d66a05a90d 100644 (file)
@@ -1314,7 +1314,9 @@ class Core_Upgrader extends WP_Upgrader {
        }
 
        function upgrade( $current, $args = array() ) {
-               global $wp_filesystem, $wp_version;
+               global $wp_filesystem;
+
+               include ABSPATH . WPINC . '/version.php'; // $wp_version;
 
                $start_time = time();
 
@@ -1333,8 +1335,9 @@ class Core_Upgrader extends WP_Upgrader {
                        return new WP_Error('up_to_date', $this->strings['up_to_date']);
 
                $res = $this->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
-               if ( is_wp_error($res) )
+               if ( ! $res || is_wp_error( $res ) ) {
                        return $res;
+               }
 
                $wp_dir = trailingslashit($wp_filesystem->abspath());
 
@@ -1421,6 +1424,7 @@ class Core_Upgrader extends WP_Upgrader {
                                'fs_method'        => $wp_filesystem->method,
                                'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ),
                                'time_taken'       => time() - $start_time,
+                               'reported'         => $wp_version,
                                'attempted'        => $current->version,
                        );
 
@@ -1868,18 +1872,21 @@ class WP_Automatic_Updater {
                if ( ! $this->should_update( $type, $item, $context ) )
                        return false;
 
+               $upgrader_item = $item;
                switch ( $type ) {
                        case 'core':
                                $skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
                                $item_name = sprintf( __( 'WordPress %s' ), $item->version );
                                break;
                        case 'theme':
-                               $theme = wp_get_theme( $item );
+                               $upgrader_item = $item->theme;
+                               $theme = wp_get_theme( $upgrader_item );
                                $item_name = $theme->Get( 'Name' );
                                $skin->feedback( __( 'Updating theme: %s' ), $item_name );
                                break;
                        case 'plugin':
-                               $plugin_data = get_plugin_data( $context . '/' . $item );
+                               $upgrader_item = $item->plugin;
+                               $plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
                                $item_name = $plugin_data['Name'];
                                $skin->feedback( __( 'Updating plugin: %s' ), $item_name );
                                break;
@@ -1891,12 +1898,17 @@ class WP_Automatic_Updater {
                }
 
                // Boom, This sites about to get a whole new splash of paint!
-               $upgrade_result = $upgrader->upgrade( $item, array(
+               $upgrade_result = $upgrader->upgrade( $upgrader_item, array(
                        'clear_update_cache' => false,
                        'pre_check_md5'      => false, /* always use partial builds if possible for core updates */
                        'attempt_rollback'   => true, /* only available for core updates */
                ) );
 
+               // if the filesystem is unavailable, false is returned.
+               if ( false === $upgrade_result ) {
+                       $upgrade_result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
+               }
+
                // Core doesn't output this, so lets append it so we don't get confused
                if ( 'core' == $type ) {
                        if ( is_wp_error( $upgrade_result ) ) {
@@ -1960,7 +1972,7 @@ class WP_Automatic_Updater {
                wp_update_plugins(); // Check for Plugin updates
                $plugin_updates = get_site_transient( 'update_plugins' );
                if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
-                       foreach ( array_keys( $plugin_updates->response ) as $plugin ) {
+                       foreach ( $plugin_updates->response as $plugin ) {
                                $this->update( 'plugin', $plugin );
                        }
                        // Force refresh of plugin update information
@@ -1971,8 +1983,8 @@ class WP_Automatic_Updater {
                wp_update_themes();  // Check for Theme updates
                $theme_updates = get_site_transient( 'update_themes' );
                if ( $theme_updates && !empty( $theme_updates->response ) ) {
-                       foreach ( array_keys( $theme_updates->response ) as $theme ) {
-                               $this->update( 'theme', $theme );
+                       foreach ( $theme_updates->response as $theme ) {
+                               $this->update( 'theme', (object) $theme );
                        }
                        // Force refresh of theme update information
                        wp_clean_themes_cache();
@@ -1987,8 +1999,21 @@ class WP_Automatic_Updater {
 
                // Clean up, and check for any pending translations
                // (Core_Upgrader checks for core updates)
-               wp_update_themes();  // Check for Theme updates
-               wp_update_plugins(); // Check for Plugin updates
+               $theme_stats = array();
+               if ( isset( $this->update_results['theme'] ) ) {
+                       foreach ( $this->update_results['theme'] as $upgrade ) {
+                               $theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
+                       }
+               }
+               wp_update_themes( $theme_stats );  // Check for Theme updates
+
+               $plugin_stats = array();
+               if ( isset( $this->update_results['plugin'] ) ) {
+                       foreach ( $this->update_results['plugin'] as $upgrade ) {
+                               $plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
+                       }
+               }
+               wp_update_plugins( $plugin_stats ); // Check for Plugin updates
 
                // Finally, Process any new translations
                $language_updates = wp_get_translation_updates();