Ticket #22704: 22704.14.diff
| File 22704.14.diff, 10.5 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/class-wp-upgrader.php
1402 1402 } 1403 1403 1404 1404 // Determines if this WordPress Core version should update to $offered_ver or not 1405 static function should_up grade_to_version( $offered_ver /* x.y.z */ ) {1405 static function should_update_to_version( $offered_ver /* x.y.z */ ) { 1406 1406 include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z 1407 1407 1408 1408 $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y … … 1551 1551 } 1552 1552 1553 1553 /** 1554 * WordPress automatic background up grader.1554 * WordPress automatic background updater. 1555 1555 * 1556 1556 * @since 3.7.0 1557 1557 */ 1558 class WP_ Automatic_Upgrader {1558 class WP_Background_Updater { 1559 1559 1560 1560 protected $update_results = array(); 1561 1561 … … 1570 1570 // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters. 1571 1571 $disabled = defined( 'AUTOMATIC_UPDATES_DISABLED' ) && AUTOMATIC_UPDATES_DISABLED; 1572 1572 1573 return apply_filters( 'auto_up grader_disabled', $disabled );1573 return apply_filters( 'auto_updates_disabled', $disabled ); 1574 1574 } 1575 1575 1576 1576 /** … … 1600 1600 break 2; 1601 1601 } 1602 1602 } 1603 return apply_filters( 'auto_up grade_is_vcs_checkout', $checkout, $context );1603 return apply_filters( 'auto_updates_is_vcs_checkout', $checkout, $context ); 1604 1604 } 1605 1605 1606 1606 /** 1607 * Tests to see if we can and should up grade a specific item.1607 * Tests to see if we can and should update a specific item. 1608 1608 */ 1609 function should_up grade( $type, $item, $context ) {1609 function should_update( $type, $item, $context ) { 1610 1610 if ( $this->is_disabled() ) 1611 1611 return false; 1612 1612 1613 // Checks to see if WP_Filesystem is set up to allow unattended up grades.1613 // Checks to see if WP_Filesystem is set up to allow unattended updates. 1614 1614 $skin = new Automatic_Upgrader_Skin; 1615 1615 if ( ! $skin->request_filesystem_credentials( false, $context ) ) 1616 1616 return false; … … 1621 1621 // Next up, do we actually have it enabled for this type of update? 1622 1622 switch ( $type ) { 1623 1623 case 'language': 1624 $up grade = ! empty( $item->autoupdate );1624 $update = ! empty( $item->autoupdate ); 1625 1625 break; 1626 1626 case 'core': 1627 $up grade = Core_Upgrader::should_upgrade_to_version( $item->current );1627 $update = Core_Upgrader::should_update_to_version( $item->current ); 1628 1628 break; 1629 1629 default: 1630 1630 case 'plugin': 1631 1631 case 'theme': 1632 $up grade = false;1632 $update = false; 1633 1633 break; 1634 1634 } 1635 1635 1636 1636 // And does the user / plugins want it? 1637 // Plugins may filter on 'auto_up grade_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes1638 if ( ! apply_filters( 'auto_up grade_' . $type, $upgrade, $item ) )1637 // Plugins may filter on 'auto_update_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes 1638 if ( ! apply_filters( 'auto_update_' . $type, $update, $item ) ) 1639 1639 return false; 1640 1640 1641 1641 // If it's a core update, are we actually compatible with its requirements? … … 1655 1655 return true; 1656 1656 } 1657 1657 1658 function up grade( $type, $item ) {1658 function update( $type, $item ) { 1659 1659 1660 $skin = new Automatic_Upgrader_Skin ();1660 $skin = new Automatic_Upgrader_Skin; 1661 1661 1662 1662 switch ( $type ) { 1663 1663 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 1664 // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter. 1665 1665 add_filter( 'update_feedback', array( $skin, 'feedback' ) ); 1666 1666 $upgrader = new Core_Upgrader( $skin ); 1667 1667 $context = ABSPATH; … … 1680 1680 break; 1681 1681 } 1682 1682 1683 // Determine whether we can and should perform this up grade.1684 if ( ! $this->should_up grade( $type, $item, $context ) )1683 // Determine whether we can and should perform this update. 1684 if ( ! $this->should_update( $type, $item, $context ) ) 1685 1685 return false; 1686 1686 1687 1687 switch ( $type ) { … … 1733 1733 } 1734 1734 1735 1735 /** 1736 * Kicks off a up grade request for each item in the upgrade "queue"1736 * Kicks off a update request for each item in the update "queue". 1737 1737 */ 1738 1738 function run() { 1739 1739 global $wpdb; … … 1741 1741 if ( ! is_main_network() || ! is_main_site() ) 1742 1742 return; 1743 1743 1744 $lock_name = 'auto_up grader.lock';1744 $lock_name = 'auto_updater.lock'; 1745 1745 1746 1746 // Try to lock 1747 1747 $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) ); … … 1772 1772 $plugin_updates = get_site_transient( 'update_plugins' ); 1773 1773 if ( $plugin_updates && !empty( $plugin_updates->response ) ) { 1774 1774 foreach ( array_keys( $plugin_updates->response ) as $plugin ) { 1775 $this->up grade( 'plugin', $plugin );1775 $this->update( 'plugin', $plugin ); 1776 1776 } 1777 1777 // Force refresh of plugin update information 1778 1778 wp_clean_plugins_cache(); … … 1783 1783 $theme_updates = get_site_transient( 'update_themes' ); 1784 1784 if ( $theme_updates && !empty( $theme_updates->response ) ) { 1785 1785 foreach ( array_keys( $theme_updates->response ) as $theme ) { 1786 $this->up grade( 'theme', $theme );1786 $this->update( 'theme', $theme ); 1787 1787 } 1788 1788 // Force refresh of theme update information 1789 1789 wp_clean_themes_cache(); 1790 1790 } 1791 1791 1792 // Next, Process any core up grade1792 // Next, Process any core update 1793 1793 wp_version_check(); // Check for Core updates 1794 1794 $extra_update_stats = array(); 1795 1795 $core_update = find_core_auto_update(); … … 1797 1797 if ( $core_update ) { 1798 1798 $start_time = time(); 1799 1799 1800 $core_update_result = $this->up grade( 'core', $core_update );1800 $core_update_result = $this->update( 'core', $core_update ); 1801 1801 delete_site_transient( 'update_core' ); 1802 1802 1803 1803 $extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true; … … 1826 1826 $language_updates = wp_get_translation_updates(); 1827 1827 if ( $language_updates ) { 1828 1828 foreach ( $language_updates as $update ) { 1829 $this->up grade( 'language', $update );1829 $this->update( 'language', $update ); 1830 1830 } 1831 1831 1832 1832 // Clear existing caches … … 1850 1850 if ( empty( $this->update_results ) ) 1851 1851 return; 1852 1852 1853 $up grade_count = 0;1854 foreach ( $this->update_results as $type => $up grades )1855 $up grade_count += count( $upgrades );1853 $update_count = 0; 1854 foreach ( $this->update_results as $type => $updates ) 1855 $update_count += count( $updates ); 1856 1856 1857 1857 $body = array(); 1858 1858 $failures = 0; … … 1910 1910 $subject = sprintf( '[%s] Background updates have finished', get_bloginfo( 'name' ) ); 1911 1911 } 1912 1912 1913 $body[] = 'UP GRADE LOG';1914 $body[] = '========== =';1913 $body[] = 'UPDATE LOG'; 1914 $body[] = '=========='; 1915 1915 $body[] = ''; 1916 1916 1917 1917 foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) { 1918 1918 if ( ! isset( $this->update_results[ $type ] ) ) 1919 1919 continue; 1920 foreach ( $this->update_results[ $type ] as $up grade ) {1921 $body[] = $up grade->name;1922 $body[] = str_repeat( '-', strlen( $up grade->name ) );1923 foreach ( $up grade->messages as $message )1920 foreach ( $this->update_results[ $type ] as $update ) { 1921 $body[] = $update->name; 1922 $body[] = str_repeat( '-', strlen( $update->name ) ); 1923 foreach ( $update->messages as $message ) 1924 1924 $body[] = " " . html_entity_decode( str_replace( '…', '...', $message ) ); 1925 if ( is_wp_error( $up grade->result ) )1926 $body[] = ' Error: [' . $up grade->result->get_error_code() . '] ' . $upgrade->result->get_error_message();1925 if ( is_wp_error( $update->result ) ) 1926 $body[] = ' Error: [' . $update->result->get_error_code() . '] ' . $update->result->get_error_message(); 1927 1927 $body[] = ''; 1928 1928 } 1929 1929 } -
src/wp-admin/includes/update.php
77 77 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 78 78 79 79 $auto_update = false; 80 $upgrader = new WP_ Automatic_Upgrader;80 $upgrader = new WP_Background_Updater; 81 81 foreach ( $updates->updates as $update ) { 82 82 if ( 'autoupdate' != $update->response ) 83 83 continue; 84 84 85 if ( ! $upgrader->should_up grade( 'core', $update, ABSPATH ) )85 if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) 86 86 continue; 87 87 88 88 if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) -
src/wp-admin/update-core.php
148 148 149 149 if ( wp_http_supports( 'ssl' ) ) { 150 150 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 151 $upgrader = new WP_ Automatic_Upgrader;151 $upgrader = new WP_Background_Updater; 152 152 $future_minor_update = (object) array( 153 153 'current' => $wp_version . '.1-update-core.php', 154 154 'version' => $wp_version . '.1-update-core.php', … … 155 155 'php_version' => $required_php_version, 156 156 'mysql_version' => $required_mysql_version, 157 157 ); 158 $should_auto_update = $upgrader->should_up grade( 'core', $future_minor_update, ABSPATH );158 $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); 159 159 if ( $should_auto_update ) 160 160 echo ' ' . __( 'Future security updates will be applied automatically.' ); 161 161 } … … 172 172 173 173 if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { 174 174 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 175 $upgrader = new WP_ Automatic_Upgrader;176 if ( wp_http_supports( 'ssl' ) && $upgrader->should_up grade( 'core', $updates[0], ABSPATH ) )175 $upgrader = new WP_Background_Updater; 176 if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) 177 177 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>'; 178 178 } 179 179 -
src/wp-includes/update.php
414 414 include_once ABSPATH . '/wp-admin/includes/admin.php'; 415 415 include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 416 416 417 $upgrader = new WP_ Automatic_Upgrader;417 $upgrader = new WP_Background_Updater; 418 418 if ( $upgrader->is_disabled() ) 419 419 return; 420 420