Changeset 25835 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 10/17/2013 11:20:56 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25828 r25835 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 … … 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_Up grader {1558 class WP_Automatic_Updater { 1559 1559 1560 1560 protected $update_results = array(); … … 1571 1571 $disabled = defined( 'AUTOMATIC_UPDATES_DISABLED' ) && AUTOMATIC_UPDATES_DISABLED; 1572 1572 1573 return apply_filters( 'auto _upgrader_disabled', $disabled );1573 return apply_filters( 'automatic_updates_disabled', $disabled ); 1574 1574 } 1575 1575 … … 1601 1601 } 1602 1602 } 1603 return apply_filters( 'auto _upgrade_is_vcs_checkout', $checkout, $context );1603 return apply_filters( 'automatic_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 ) ) … … 1619 1619 return false; 1620 1620 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 ); 1635 1626 1636 1627 // 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 ) )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 ) ) 1639 1630 return false; 1640 1631 … … 1656 1647 } 1657 1648 1658 function up grade( $type, $item ) {1659 1660 $skin = new Automatic_Upgrader_Skin ();1649 function update( $type, $item ) { 1650 1651 $skin = new Automatic_Upgrader_Skin; 1661 1652 1662 1653 switch ( $type ) { 1663 1654 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. 1665 1656 add_filter( 'update_feedback', array( $skin, 'feedback' ) ); 1666 1657 $upgrader = new Core_Upgrader( $skin ); … … 1681 1672 } 1682 1673 1683 // Determine whether we can and should perform this up grade.1684 if ( ! $this->should_up grade( $type, $item, $context ) )1674 // Determine whether we can and should perform this update. 1675 if ( ! $this->should_update( $type, $item, $context ) ) 1685 1676 return false; 1686 1677 … … 1734 1725 1735 1726 /** 1736 * Kicks off a up grade request for each item in the upgrade "queue"1727 * Kicks off a update request for each item in the update "queue". 1737 1728 */ 1738 1729 function run() { … … 1742 1733 return; 1743 1734 1744 $lock_name = 'auto_up grader.lock';1735 $lock_name = 'auto_updater.lock'; 1745 1736 1746 1737 // Try to lock … … 1773 1764 if ( $plugin_updates && !empty( $plugin_updates->response ) ) { 1774 1765 foreach ( array_keys( $plugin_updates->response ) as $plugin ) { 1775 $this->up grade( 'plugin', $plugin );1766 $this->update( 'plugin', $plugin ); 1776 1767 } 1777 1768 // Force refresh of plugin update information … … 1784 1775 if ( $theme_updates && !empty( $theme_updates->response ) ) { 1785 1776 foreach ( array_keys( $theme_updates->response ) as $theme ) { 1786 $this->up grade( 'theme', $theme );1777 $this->update( 'theme', $theme ); 1787 1778 } 1788 1779 // Force refresh of theme update information … … 1790 1781 } 1791 1782 1792 // Next, Process any core up grade1783 // Next, Process any core update 1793 1784 wp_version_check(); // Check for Core updates 1794 1785 $extra_update_stats = array(); … … 1798 1789 $start_time = time(); 1799 1790 1800 $core_update_result = $this->up grade( 'core', $core_update );1791 $core_update_result = $this->update( 'core', $core_update ); 1801 1792 delete_site_transient( 'update_core' ); 1802 1793 … … 1827 1818 if ( $language_updates ) { 1828 1819 foreach ( $language_updates as $update ) { 1829 $this->up grade( 'language', $update );1820 $this->update( 'language', $update ); 1830 1821 } 1831 1822 … … 1851 1842 return; 1852 1843 1853 $up grade_count = 0;1854 foreach ( $this->update_results as $type => $up grades )1855 $up grade_count += count( $upgrades );1844 $update_count = 0; 1845 foreach ( $this->update_results as $type => $updates ) 1846 $update_count += count( $updates ); 1856 1847 1857 1848 $body = array(); … … 1911 1902 } 1912 1903 1913 $body[] = 'UP GRADE LOG';1914 $body[] = '========== =';1904 $body[] = 'UPDATE LOG'; 1905 $body[] = '=========='; 1915 1906 $body[] = ''; 1916 1907 … … 1918 1909 if ( ! isset( $this->update_results[ $type ] ) ) 1919 1910 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 )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 ) 1924 1915 $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();1916 if ( is_wp_error( $update->result ) ) 1917 $body[] = ' Error: [' . $update->result->get_error_code() . '] ' . $update->result->get_error_message(); 1927 1918 $body[] = ''; 1928 1919 }
Note: See TracChangeset
for help on using the changeset viewer.