Make WordPress Core

Ticket #27365: 27365.3.diff

File 27365.3.diff, 9.9 KB (added by dd32, 9 years ago)
  • src/wp-admin/includes/class-wp-upgrader.php

    class WP_Upgrader { 
    552552
    553553                $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
    554554
    555555                /**
    556556                 * Filter the install response after the installation has finished.
    557557                 *
    558558                 * @since 2.8.0
    559559                 *
    560560                 * @param bool  $response   Install response.
    561561                 * @param array $hook_extra Extra arguments passed to hooked filters.
    562562                 * @param array $result     Installation result data.
    563563                 */
    564564                $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
    565565
    566566                if ( is_wp_error($res) ) {
    567                         $this->result = $res;
    568567                        return $res;
    569568                }
    570569
    571570                //Bombard the calling function will all the info which we've just used.
    572571                return $this->result;
    573572        }
    574573
    575574        /**
    576575         * Run an upgrade/install.
    577576         *
    578577         * Attempts to download the package (if it is not a local file), unpack it, and
    579578         * install it in the destination folder.
    580579         *
    581580         * @since 2.8.0
    582581         * @access public
    class Plugin_Upgrader extends WP_Upgrade 
    835834         */
    836835        public function install( $package, $args = array() ) {
    837836
    838837                $defaults = array(
    839838                        'clear_update_cache' => true,
    840839                );
    841840                $parsed_args = wp_parse_args( $args, $defaults );
    842841
    843842                $this->init();
    844843                $this->install_strings();
    845844
    846845                add_filter('upgrader_source_selection', array($this, 'check_package') );
    847846                // Clear cache so wp_update_plugins() knows about the new plugin.
    848847                add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
    849848
    850                 $this->run( array(
     849                $result = $this->run( array(
    851850                        'package' => $package,
    852851                        'destination' => WP_PLUGIN_DIR,
    853852                        'clear_destination' => false, // Do not overwrite files.
    854853                        'clear_working' => true,
    855854                        'hook_extra' => array(
    856855                                'type' => 'plugin',
    857856                                'action' => 'install',
    858857                        )
    859858                ) );
    860859
    861860                remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
    862861                remove_filter('upgrader_source_selection', array($this, 'check_package') );
    863862
    864                 if ( ! $this->result || is_wp_error($this->result) )
    865                         return $this->result;
     863                if ( ! $result || is_wp_error( $result ) )
     864                        return $result;
    866865
    867866                // Force refresh of plugin update information
    868867                wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
    869868
    870869                return true;
    871870        }
    872871
    873872        /**
    874873         * Upgrade a plugin.
    875874         *
    876875         * @since 2.8.0
    877876         * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
    878877         * @access public
    879878         *
    880879         * @param string $plugin The basename path to the main plugin file.
    class Plugin_Upgrader extends WP_Upgrade 
    900899                if ( !isset( $current->response[ $plugin ] ) ) {
    901900                        $this->skin->before();
    902901                        $this->skin->set_result(false);
    903902                        $this->skin->error('up_to_date');
    904903                        $this->skin->after();
    905904                        return false;
    906905                }
    907906
    908907                // Get the URL to the zip file
    909908                $r = $current->response[ $plugin ];
    910909
    911910                add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
    912911                add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
    913912                //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
    914913
    915                 $this->run( array(
     914                $result = $this->run( array(
    916915                        'package' => $r->package,
    917916                        'destination' => WP_PLUGIN_DIR,
    918917                        'clear_destination' => true,
    919918                        'clear_working' => true,
    920919                        'hook_extra' => array(
    921920                                'plugin' => $plugin,
    922921                                'type' => 'plugin',
    923922                                'action' => 'update',
    924923                        ),
    925924                ) );
    926925
    927926                // Cleanup our hooks, in case something else does a upgrade on this connection.
    928927                remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
    929928                remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
    930929
    931                 if ( ! $this->result || is_wp_error($this->result) )
    932                         return $this->result;
     930                if ( ! $result || is_wp_error( $result ) )
     931                        return $result;
    933932
    934933                // Force refresh of plugin update information
    935934                wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
    936935
    937936                return true;
    938937        }
    939938
    940939        /**
    941940         * Bulk upgrade several plugins at once.
    942941         *
    943942         * @since 2.8.0
    944943         * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
    945944         * @access public
    946945         *
    947946         * @param array $plugins Array of the basename paths of the plugins' main files.
    class Plugin_Upgrader extends WP_Upgrade 
    10121011                        $r = $current->response[ $plugin ];
    10131012
    10141013                        $this->skin->plugin_active = is_plugin_active($plugin);
    10151014
    10161015                        $result = $this->run( array(
    10171016                                'package' => $r->package,
    10181017                                'destination' => WP_PLUGIN_DIR,
    10191018                                'clear_destination' => true,
    10201019                                'clear_working' => true,
    10211020                                'is_multi' => true,
    10221021                                'hook_extra' => array(
    10231022                                        'plugin' => $plugin
    10241023                                )
    10251024                        ) );
    10261025
    1027                         $results[$plugin] = $this->result;
     1026                        $results[$plugin] = $result;
    10281027
    10291028                        // Prevent credentials auth screen from displaying multiple times
    10301029                        if ( false === $result )
    10311030                                break;
    10321031                } //end foreach $plugins
    10331032
    10341033                $this->maintenance_mode(false);
    10351034
    10361035                /**
    10371036                 * Fires when the bulk upgrader process is complete.
    10381037                 *
    10391038                 * @since 3.6.0
    10401039                 *
    10411040                 * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
    10421041                 *                              be a Theme_Upgrader or Core_Upgrade instance.
    class Theme_Upgrader extends WP_Upgrader 
    14021401        public function install( $package, $args = array() ) {
    14031402
    14041403                $defaults = array(
    14051404                        'clear_update_cache' => true,
    14061405                );
    14071406                $parsed_args = wp_parse_args( $args, $defaults );
    14081407
    14091408                $this->init();
    14101409                $this->install_strings();
    14111410
    14121411                add_filter('upgrader_source_selection', array($this, 'check_package') );
    14131412                add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
    14141413                // Clear cache so wp_update_themes() knows about the new theme.
    14151414                add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
    14161415
    1417                 $this->run( array(
     1416                $result = $this->run( array(
    14181417                        'package' => $package,
    14191418                        'destination' => get_theme_root(),
    14201419                        'clear_destination' => false, //Do not overwrite files.
    14211420                        'clear_working' => true,
    14221421                        'hook_extra' => array(
    14231422                                'type' => 'theme',
    14241423                                'action' => 'install',
    14251424                        ),
    14261425                ) );
    14271426
    14281427                remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
    14291428                remove_filter('upgrader_source_selection', array($this, 'check_package') );
    14301429                remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));
    14311430
    1432                 if ( ! $this->result || is_wp_error($this->result) )
    1433                         return $this->result;
     1431                if ( ! $result || is_wp_error( $result ) )
     1432                        return $result;
    14341433
    14351434                // Refresh the Theme Update information
    14361435                wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
    14371436
    14381437                return true;
    14391438        }
    14401439
    14411440        /**
    14421441         * Upgrade a theme.
    14431442         *
    14441443         * @since 2.8.0
    14451444         * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
    14461445         * @access public
    14471446         *
    14481447         * @param string $theme The theme slug.
    class Theme_Upgrader extends WP_Upgrader 
    14841483                        'package' => $r['package'],
    14851484                        'destination' => get_theme_root( $theme ),
    14861485                        'clear_destination' => true,
    14871486                        'clear_working' => true,
    14881487                        'hook_extra' => array(
    14891488                                'theme' => $theme,
    14901489                                'type' => 'theme',
    14911490                                'action' => 'update',
    14921491                        ),
    14931492                ) );
    14941493
    14951494                remove_filter('upgrader_pre_install', array($this, 'current_before'));
    14961495                remove_filter('upgrader_post_install', array($this, 'current_after'));
    14971496                remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
    14981497
    1499                 if ( ! $this->result || is_wp_error($this->result) )
    1500                         return $this->result;
     1498                if ( ! $result || is_wp_error( $result ) )
     1499                        return $result;
    15011500
    15021501                wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
    15031502
    15041503                return true;
    15051504        }
    15061505
    15071506        /**
    15081507         * Upgrade several themes at once.
    15091508         *
    15101509         * @since 3.0.0
    15111510         * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
    15121511         * @access public
    15131512         *
    15141513         * @param array $themes The theme slugs.
    15151514         * @param array $args {
    class Theme_Upgrader extends WP_Upgrader 
    15781577
    15791578                        // Get the URL to the zip file
    15801579                        $r = $current->response[ $theme ];
    15811580
    15821581                        $result = $this->run( array(
    15831582                                'package' => $r['package'],
    15841583                                'destination' => get_theme_root( $theme ),
    15851584                                'clear_destination' => true,
    15861585                                'clear_working' => true,
    15871586                                'is_multi' => true,
    15881587                                'hook_extra' => array(
    15891588                                        'theme' => $theme
    15901589                                ),
    15911590                        ) );
    15921591
    1593                         $results[$theme] = $this->result;
     1592                        $results[$theme] = $result;
    15941593
    15951594                        // Prevent credentials auth screen from displaying multiple times
    15961595                        if ( false === $result )
    15971596                                break;
    15981597                } //end foreach $plugins
    15991598
    16001599                $this->maintenance_mode(false);
    16011600
    16021601                /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
    16031602                do_action( 'upgrader_process_complete', $this, array(
    16041603                        'action' => 'update',
    16051604                        'type' => 'theme',
    16061605                        'bulk' => true,
    16071606                        'themes' => $themes,
    16081607                ) );
    class Language_Pack_Upgrader extends WP_ 
    20192018                        $options = array(
    20202019                                'package' => $language_update->package,
    20212020                                'destination' => $destination,
    20222021                                'clear_destination' => false,
    20232022                                'abort_if_destination_exists' => false, // We expect the destination to exist.
    20242023                                'clear_working' => true,
    20252024                                'is_multi' => true,
    20262025                                'hook_extra' => array(
    20272026                                        'language_update_type' => $language_update->type,
    20282027                                        'language_update' => $language_update,
    20292028                                )
    20302029                        );
    20312030
    20322031                        $result = $this->run( $options );
    20332032
    2034                         $results[] = $this->result;
     2033                        $results[] = $result;
    20352034
    20362035                        // Prevent credentials auth screen from displaying multiple times.
    20372036                        if ( false === $result )
    20382037                                break;
    20392038                }
    20402039
    20412040                $this->skin->bulk_footer();
    20422041
    20432042                $this->skin->footer();
    20442043
    20452044                // Clean up our hooks, in case something else does an upgrade on this connection.
    20462045                remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
    20472046
    20482047                if ( $parsed_args['clear_update_cache'] ) {
    20492048                        wp_clean_update_cache();