WordPress.org

Make WordPress Core

Changeset 25835


Ignore:
Timestamp:
10/17/13 23:20:56 (3 years ago)
Author:
nacin
Message:

In automatic background updates, standardize on 'update'.

New, final filter names:

  • auto_update_{$type} (plugin, theme, core, language)
  • automatic_updates_is_vcs_checkout
  • automatic_updates_disabled

New class name is WP_Automatic_Updater. Method names include update() and should_update().

see #22704.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/about.php

    r25834 r25835  
    4545            if ( $can_auto_update ) { 
    4646                require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
    47                 $upgrader = new WP_Automatic_Upgrader; 
     47                $upgrader = new WP_Automatic_Updater; 
    4848                $future_minor_update = (object) array( 
    4949                    'current'       => $wp_version . '.1-about.php', 
     
    5252                    'mysql_version' => $required_mysql_version, 
    5353                ); 
    54                 $can_auto_update = $upgrader->should_upgrade( 'core', $future_minor_update, ABSPATH ); 
     54                $can_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); 
    5555            } 
    5656            if ( $can_auto_update ) : ?> 
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25828 r25835  
    14031403 
    14041404    // Determines if this WordPress Core version should update to $offered_ver or not 
    1405     static function should_upgrade_to_version( $offered_ver /* x.y.z */ ) { 
     1405    static function should_update_to_version( $offered_ver /* x.y.z */ ) { 
    14061406        include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z 
    14071407 
     
    15521552 
    15531553/** 
    1554  * WordPress automatic background upgrader. 
     1554 * WordPress automatic background updater. 
    15551555 * 
    15561556 * @since 3.7.0 
    15571557 */ 
    1558 class WP_Automatic_Upgrader { 
     1558class WP_Automatic_Updater { 
    15591559 
    15601560    protected $update_results = array(); 
     
    15711571        $disabled = defined( 'AUTOMATIC_UPDATES_DISABLED' ) && AUTOMATIC_UPDATES_DISABLED; 
    15721572 
    1573         return apply_filters( 'auto_upgrader_disabled', $disabled ); 
     1573        return apply_filters( 'automatic_updates_disabled', $disabled ); 
    15741574    } 
    15751575 
     
    16011601            } 
    16021602        } 
    1603         return apply_filters( 'auto_upgrade_is_vcs_checkout', $checkout, $context ); 
     1603        return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context ); 
    16041604    } 
    16051605 
    16061606    /** 
    1607      * Tests to see if we can and should upgrade a specific item. 
     1607     * Tests to see if we can and should update a specific item. 
    16081608     */ 
    1609     function should_upgrade( $type, $item, $context ) { 
     1609    function should_update( $type, $item, $context ) { 
    16101610        if ( $this->is_disabled() ) 
    16111611            return false; 
    16121612 
    1613         // Checks to see if WP_Filesystem is set up to allow unattended upgrades. 
     1613        // Checks to see if WP_Filesystem is set up to allow unattended updates. 
    16141614        $skin = new Automatic_Upgrader_Skin; 
    16151615        if ( ! $skin->request_filesystem_credentials( false, $context ) ) 
     
    16191619            return false; 
    16201620 
    1621         // Next up, do we actually have it enabled for this type of update? 
    1622         switch ( $type ) { 
    1623             case 'language': 
    1624                 $upgrade = ! empty( $item->autoupdate ); 
    1625                 break; 
    1626             case 'core': 
    1627                 $upgrade = Core_Upgrader::should_upgrade_to_version( $item->current ); 
    1628                 break; 
    1629             default: 
    1630             case 'plugin': 
    1631             case 'theme': 
    1632                 $upgrade = false; 
    1633                 break; 
    1634         } 
     1621        // Next up, is this an item we can update? 
     1622        if ( 'core' == $type ) 
     1623            $update = Core_Upgrader::should_update_to_version( $item->current ); 
     1624        else 
     1625            $update = ! empty( $item->autoupdate ); 
    16351626 
    16361627        // And does the user / plugins want it? 
    1637         // Plugins may filter on 'auto_upgrade_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes 
    1638         if ( ! apply_filters( 'auto_upgrade_' . $type, $upgrade, $item ) ) 
     1628        // Plugins may filter on 'auto_update_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes 
     1629        if ( ! apply_filters( 'auto_update_' . $type, $update, $item ) ) 
    16391630            return false; 
    16401631 
     
    16561647    } 
    16571648 
    1658     function upgrade( $type, $item ) { 
    1659  
    1660         $skin = new Automatic_Upgrader_Skin(); 
     1649    function update( $type, $item ) { 
     1650 
     1651        $skin = new Automatic_Upgrader_Skin; 
    16611652 
    16621653        switch ( $type ) { 
    16631654            case 'core': 
    1664                 // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter 
     1655                // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter. 
    16651656                add_filter( 'update_feedback', array( $skin, 'feedback' ) ); 
    16661657                $upgrader = new Core_Upgrader( $skin ); 
     
    16811672        } 
    16821673 
    1683         // Determine whether we can and should perform this upgrade. 
    1684         if ( ! $this->should_upgrade( $type, $item, $context ) ) 
     1674        // Determine whether we can and should perform this update. 
     1675        if ( ! $this->should_update( $type, $item, $context ) ) 
    16851676            return false; 
    16861677 
     
    17341725 
    17351726    /** 
    1736      * Kicks off a upgrade request for each item in the upgrade "queue" 
     1727     * Kicks off a update request for each item in the update "queue". 
    17371728     */ 
    17381729    function run() { 
     
    17421733            return; 
    17431734 
    1744         $lock_name = 'auto_upgrader.lock'; 
     1735        $lock_name = 'auto_updater.lock'; 
    17451736 
    17461737        // Try to lock 
     
    17731764        if ( $plugin_updates && !empty( $plugin_updates->response ) ) { 
    17741765            foreach ( array_keys( $plugin_updates->response ) as $plugin ) { 
    1775                 $this->upgrade( 'plugin', $plugin ); 
     1766                $this->update( 'plugin', $plugin ); 
    17761767            } 
    17771768            // Force refresh of plugin update information 
     
    17841775        if ( $theme_updates && !empty( $theme_updates->response ) ) { 
    17851776            foreach ( array_keys( $theme_updates->response ) as $theme ) { 
    1786                 $this->upgrade( 'theme', $theme ); 
     1777                $this->update( 'theme', $theme ); 
    17871778            } 
    17881779            // Force refresh of theme update information 
     
    17901781        } 
    17911782 
    1792         // Next, Process any core upgrade 
     1783        // Next, Process any core update 
    17931784        wp_version_check(); // Check for Core updates 
    17941785        $extra_update_stats = array(); 
     
    17981789            $start_time = time(); 
    17991790 
    1800             $core_update_result = $this->upgrade( 'core', $core_update ); 
     1791            $core_update_result = $this->update( 'core', $core_update ); 
    18011792            delete_site_transient( 'update_core' ); 
    18021793 
     
    18271818        if ( $language_updates ) { 
    18281819            foreach ( $language_updates as $update ) { 
    1829                 $this->upgrade( 'language', $update ); 
     1820                $this->update( 'language', $update ); 
    18301821            } 
    18311822 
     
    18511842            return; 
    18521843 
    1853         $upgrade_count = 0; 
    1854         foreach ( $this->update_results as $type => $upgrades ) 
    1855             $upgrade_count += count( $upgrades ); 
     1844        $update_count = 0; 
     1845        foreach ( $this->update_results as $type => $updates ) 
     1846            $update_count += count( $updates ); 
    18561847 
    18571848        $body = array(); 
     
    19111902        } 
    19121903 
    1913         $body[] = 'UPGRADE LOG'; 
    1914         $body[] = '==========='; 
     1904        $body[] = 'UPDATE LOG'; 
     1905        $body[] = '=========='; 
    19151906        $body[] = ''; 
    19161907 
     
    19181909            if ( ! isset( $this->update_results[ $type ] ) ) 
    19191910                continue; 
    1920             foreach ( $this->update_results[ $type ] as $upgrade ) { 
    1921                 $body[] = $upgrade->name; 
    1922                 $body[] = str_repeat( '-', strlen( $upgrade->name ) ); 
    1923                 foreach ( $upgrade->messages as $message ) 
     1911            foreach ( $this->update_results[ $type ] as $update ) { 
     1912                $body[] = $update->name; 
     1913                $body[] = str_repeat( '-', strlen( $update->name ) ); 
     1914                foreach ( $update->messages as $message ) 
    19241915                    $body[] = "  " . html_entity_decode( str_replace( '…', '...', $message ) ); 
    1925                 if ( is_wp_error( $upgrade->result ) ) 
    1926                     $body[] = '  Error: [' . $upgrade->result->get_error_code() . '] ' . $upgrade->result->get_error_message(); 
     1916                if ( is_wp_error( $update->result ) ) 
     1917                    $body[] = '  Error: [' . $update->result->get_error_code() . '] ' . $update->result->get_error_message(); 
    19271918                $body[] = ''; 
    19281919            } 
  • trunk/src/wp-admin/includes/update.php

    r25823 r25835  
    7878 
    7979    $auto_update = false; 
    80     $upgrader = new WP_Automatic_Upgrader; 
     80    $upgrader = new WP_Automatic_Updater; 
    8181    foreach ( $updates->updates as $update ) { 
    8282        if ( 'autoupdate' != $update->response ) 
    8383            continue; 
    8484 
    85         if ( ! $upgrader->should_upgrade( 'core', $update, ABSPATH ) ) 
     85        if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) 
    8686            continue; 
    8787 
  • trunk/src/wp-admin/update-core.php

    r25823 r25835  
    149149        if ( wp_http_supports( 'ssl' ) ) { 
    150150            require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
    151             $upgrader = new WP_Automatic_Upgrader; 
     151            $upgrader = new WP_Automatic_Updater; 
    152152            $future_minor_update = (object) array( 
    153153                'current'       => $wp_version . '.1-update-core.php', 
     
    156156                'mysql_version' => $required_mysql_version, 
    157157            ); 
    158             $should_auto_update = $upgrader->should_upgrade( 'core', $future_minor_update, ABSPATH ); 
     158            $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); 
    159159            if ( $should_auto_update ) 
    160160                echo ' ' . __( 'Future security updates will be applied automatically.' ); 
     
    173173    if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { 
    174174        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
    175         $upgrader = new WP_Automatic_Upgrader; 
    176         if ( wp_http_supports( 'ssl' ) && $upgrader->should_upgrade( 'core', $updates[0], ABSPATH ) ) 
     175        $upgrader = new WP_Automatic_Updater; 
     176        if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) 
    177177            echo '<div class="updated inline"><p><strong>BETA TESTERS:</strong> This site is set up to install updates of future beta versions automatically.</p></div>'; 
    178178    } 
  • trunk/src/wp-includes/update.php

    r25825 r25835  
    415415    include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 
    416416 
    417     $upgrader = new WP_Automatic_Upgrader; 
     417    $upgrader = new WP_Automatic_Updater; 
    418418    if ( $upgrader->is_disabled() ) 
    419419        return; 
Note: See TracChangeset for help on using the changeset viewer.