Changeset 25823
- Timestamp:
- 10/17/2013 12:54:15 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25822 r25823 1552 1552 1553 1553 /** 1554 * WordPress Automatic Upgrader helper class1554 * WordPress automatic background upgrader. 1555 1555 * 1556 1556 * @since 3.7.0 … … 1558 1558 class WP_Automatic_Upgrader { 1559 1559 1560 static $upgrade_results = array();1561 1562 static function upgrader_disabled() {1563 // That's a no if you don't want files changes1560 protected $update_results = array(); 1561 1562 function is_disabled() { 1563 // Background updates are disabled if you don't want file changes. 1564 1564 if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) 1565 1565 return true; 1566 1566 1567 // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters1568 if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED )1569 return true;1570 1571 1567 if ( defined( 'WP_INSTALLING' ) ) 1572 1568 return true; 1573 1569 1574 return apply_filters( 'auto_upgrader_disabled', false ); 1570 // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters. 1571 $disabled = defined( 'AUTOMATIC_UPDATES_DISABLED' ) && AUTOMATIC_UPDATES_DISABLED; 1572 1573 return apply_filters( 'auto_upgrader_disabled', $disabled ); 1575 1574 } 1576 1575 … … 1578 1577 * Check for GIT/SVN checkouts. 1579 1578 */ 1580 staticfunction is_vcs_checkout( $context ) {1579 function is_vcs_checkout( $context ) { 1581 1580 $context_dirs = array( untrailingslashit( $context ) ); 1582 1581 if ( $context !== ABSPATH ) … … 1608 1607 * Tests to see if we can and should upgrade a specific item. 1609 1608 */ 1610 static function should_auto_update( $type, $item, $context ) { 1609 function should_upgrade( $type, $item, $context ) { 1610 if ( $this->is_disabled() ) 1611 return false; 1611 1612 1612 1613 // Checks to see if WP_Filesystem is set up to allow unattended upgrades. … … 1615 1616 return false; 1616 1617 1617 if ( self::upgrader_disabled() ) 1618 return false; 1619 1620 if ( self::is_vcs_checkout( $context ) ) 1618 if ( $this->is_vcs_checkout( $context ) ) 1621 1619 return false; 1622 1620 … … 1658 1656 } 1659 1657 1660 staticfunction upgrade( $type, $item ) {1658 function upgrade( $type, $item ) { 1661 1659 1662 1660 $skin = new Automatic_Upgrader_Skin(); … … 1684 1682 1685 1683 // Determine whether we can and should perform this upgrade. 1686 if ( ! self::should_auto_update( $type, $item, $context ) )1684 if ( ! $this->should_upgrade( $type, $item, $context ) ) 1687 1685 return false; 1688 1686 … … 1725 1723 } 1726 1724 1727 self::$upgrade_results[ $type ][] = (object) array(1725 $this->update_results[ $type ][] = (object) array( 1728 1726 'item' => $item, 1729 1727 'result' => $upgrade_result, … … 1738 1736 * Kicks off a upgrade request for each item in the upgrade "queue" 1739 1737 */ 1740 static function perform_auto_updates() { 1741 1738 function run() { 1742 1739 $lock_name = 'auto_upgrader.lock'; 1743 1740 if ( get_site_option( $lock_name ) ) { … … 1763 1760 if ( $plugin_updates && !empty( $plugin_updates->response ) ) { 1764 1761 foreach ( array_keys( $plugin_updates->response ) as $plugin ) { 1765 self::upgrade( 'plugin', $plugin );1762 $this->upgrade( 'plugin', $plugin ); 1766 1763 } 1767 1764 // Force refresh of plugin update information … … 1774 1771 if ( $theme_updates && !empty( $theme_updates->response ) ) { 1775 1772 foreach ( array_keys( $theme_updates->response ) as $theme ) { 1776 self::upgrade( 'theme', $theme );1773 $this->upgrade( 'theme', $theme ); 1777 1774 } 1778 1775 // Force refresh of theme update information … … 1784 1781 $extra_update_stats = array(); 1785 1782 $core_update = find_core_auto_update(); 1783 1786 1784 if ( $core_update ) { 1787 1785 $start_time = time(); 1788 $core_update_result = self::upgrade( 'core', $core_update ); 1786 1787 $core_update_result = $this->upgrade( 'core', $core_update ); 1789 1788 delete_site_transient( 'update_core' ); 1789 1790 1790 $extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true; 1791 1791 $extra_update_stats['error_data'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_data() : ''; 1792 1792 1793 if ( is_wp_error( $core_update_result ) && 'rollback_was_required' == $core_update_result->get_error_code() ) { 1793 1794 $rollback_data = $core_update_result->get_error_data(); … … 1797 1798 $extra_update_stats['rollback_data'] = is_wp_error( $rollback_data['rollback'] ) ? $rollback_data['rollback']->get_error_data() : ''; 1798 1799 } 1800 1799 1801 $extra_update_stats['fs_method'] = $GLOBALS['wp_filesystem']->method; 1800 1802 $extra_update_stats['fs_method_forced'] = defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ); … … 1812 1814 if ( $language_updates ) { 1813 1815 foreach ( $language_updates as $update ) { 1814 self::upgrade( 'language', $update );1816 $this->upgrade( 'language', $update ); 1815 1817 } 1818 1816 1819 // Clear existing caches 1817 1820 wp_clean_plugins_cache(); … … 1824 1827 } 1825 1828 1826 /** 1827 * Filter whether to email an update summary to the site administrator. 1828 * 1829 * @since 3.7.0 1830 * 1831 * @param bool Whether or not email should be sent to administrator. Default true. 1832 * @param bool|array $core_update An array of core update data, false otherwise. 1833 * @param object $theme_updates Object containing theme update properties. 1834 * @param object $plugin_updates Object containing plugin update properties. 1835 * @param array $language_updates Array containing the Language updates available. 1836 * @param array $upgrade_results Array of the upgrade results keyed by upgrade type, and plugin/theme slug. 1837 */ 1838 if ( apply_filters( 'enable_auto_upgrade_email', true, $core_update, $theme_updates, $plugin_updates, $language_updates, self::$upgrade_results ) ) 1839 self::send_email(); 1829 $this->send_debug_email(); 1840 1830 1841 1831 // Clear the lock … … 1844 1834 } 1845 1835 1846 static function send_email() {1847 1848 if ( empty( self::$upgrade_results ) )1836 function send_debug_email() { 1837 1838 if ( empty( $this->update_results ) ) 1849 1839 return; 1850 1840 1851 1841 $upgrade_count = 0; 1852 foreach ( self::$upgrade_results as $type => $upgrades )1842 foreach ( $this->update_results as $type => $upgrades ) 1853 1843 $upgrade_count += count( $upgrades ); 1854 1844 … … 1859 1849 1860 1850 // Core 1861 if ( isset( self::$upgrade_results['core'] ) ) {1862 $result = self::$upgrade_results['core'][0];1851 if ( isset( $this->update_results['core'] ) ) { 1852 $result = $this->update_results['core'][0]; 1863 1853 if ( $result->result && ! is_wp_error( $result->result ) ) { 1864 1854 $body[] = sprintf( 'SUCCESS: WordPress was successfully updated to %s', $result->name ); … … 1872 1862 // Plugins, Themes, Languages 1873 1863 foreach ( array( 'plugin', 'theme', 'language' ) as $type ) { 1874 if ( ! isset( self::$upgrade_results[ $type ] ) )1864 if ( ! isset( $this->update_results[ $type ] ) ) 1875 1865 continue; 1876 $success_items = wp_list_filter( self::$upgrade_results[ $type ], array( 'result' => true ) );1866 $success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) ); 1877 1867 if ( $success_items ) { 1878 1868 $body[] = "The following {$type}s were successfully updated:"; … … 1880 1870 $body[] = ' * SUCCESS: ' . $name; 1881 1871 } 1882 if ( $success_items != self::$upgrade_results[ $type ] ) {1872 if ( $success_items != $this->update_results[ $type ] ) { 1883 1873 // Failed updates 1884 1874 $body[] = "The following {$type}s failed to update:"; 1885 foreach ( self::$upgrade_results[ $type ] as $item ) {1875 foreach ( $this->update_results[ $type ] as $item ) { 1886 1876 if ( ! $item->result || is_wp_error( $item->result ) ) { 1887 1877 $body[] = ' * FAILED: ' . $item->name; … … 1914 1904 1915 1905 foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) { 1916 if ( ! isset( self::$upgrade_results[ $type ] ) )1906 if ( ! isset( $this->update_results[ $type ] ) ) 1917 1907 continue; 1918 foreach ( self::$upgrade_results[ $type ] as $upgrade ) {1908 foreach ( $this->update_results[ $type ] as $upgrade ) { 1919 1909 $body[] = $upgrade->name; 1920 1910 $body[] = str_repeat( '-', strlen( $upgrade->name ) ); -
trunk/src/wp-admin/includes/update.php
r25810 r25823 78 78 79 79 $auto_update = false; 80 $upgrader = new WP_Automatic_Upgrader; 80 81 foreach ( $updates->updates as $update ) { 81 82 if ( 'autoupdate' != $update->response ) 82 83 continue; 83 84 84 if ( ! WP_Automatic_Upgrader::should_auto_update( 'core', $update, ABSPATH ) )85 if ( ! $upgrader->should_upgrade( 'core', $update, ABSPATH ) ) 85 86 continue; 86 87 -
trunk/src/wp-admin/update-core.php
r25820 r25823 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 152 $future_minor_update = (object) array( 152 153 'current' => $wp_version . '.1-update-core.php', … … 155 156 'mysql_version' => $required_mysql_version, 156 157 ); 157 $should_auto_update = WP_Automatic_Upgrader::should_auto_update( 'core', $future_minor_update, ABSPATH );158 $should_auto_update = $upgrader->should_upgrade( 'core', $future_minor_update, ABSPATH ); 158 159 if ( $should_auto_update ) 159 160 echo ' ' . __( 'Future security updates will be applied automatically.' ); … … 172 173 if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { 173 174 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 174 if ( wp_http_supports( 'ssl' ) && WP_Automatic_Upgrader::should_auto_update( 'core', $updates[0], ABSPATH ) ) 175 $upgrader = new WP_Automatic_Upgrader; 176 if ( wp_http_supports( 'ssl' ) && $upgrader->should_upgrade( 'core', $updates[0], ABSPATH ) ) 175 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>'; 176 178 } -
trunk/src/wp-includes/update.php
r25810 r25823 407 407 408 408 /** 409 * Cron entry which runs the WordPress Automatic Updates409 * Performs WordPress automatic background updates. 410 410 * 411 411 * @since 3.7.0 412 412 */ 413 function wp_ auto_updates_maybe_update() {413 function wp_maybe_auto_update() { 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 if ( WP_Automatic_Upgrader::upgrader_disabled() ) 417 $upgrader = new WP_Automatic_Upgrader; 418 if ( $upgrader->is_disabled() ) 418 419 return; 419 420 420 WP_Automatic_Upgrader::perform_auto_updates();421 $upgrader->run(); 421 422 } 422 423 … … 566 567 wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); 567 568 568 if ( !wp_next_scheduled( 'wp_auto_updates_maybe_update' ) && ! defined( 'WP_INSTALLING' ) ) 569 wp_schedule_event( time(), 'twicedaily', 'wp_auto_updates_maybe_update' ); 570 569 if ( !wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) 570 wp_schedule_event( time(), 'twicedaily', 'wp_maybe_auto_update' ); 571 571 } 572 572 … … 592 592 add_action( 'upgrader_process_complete', 'wp_update_themes' ); 593 593 594 // Automatic Updates - Cron callback 595 add_action( 'wp_auto_updates_maybe_update', 'wp_auto_updates_maybe_update' ); 594 add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); 596 595 597 596 add_action('init', 'wp_schedule_update_checks');
Note: See TracChangeset
for help on using the changeset viewer.