Changeset 25633 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 09/27/2013 11:20:08 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25599 r25633 1102 1102 if ( $update ) 1103 1103 $update = array( $update ); 1104 return $this->bulk_upgrade( $update ); 1104 $results = $this->bulk_upgrade( $update ); 1105 return $results[0]; 1105 1106 } 1106 1107 1107 1108 function bulk_upgrade( $language_updates = array() ) { 1109 global $wp_filesystem; 1108 1110 1109 1111 $this->init(); … … 1134 1136 $this->update_count = count( $language_updates ); 1135 1137 $this->update_current = 0; 1138 1139 // The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists, 1140 // as we then may need to create a /plugins or /themes directory inside of it. 1141 $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR ); 1142 if ( ! $wp_filesystem->exists( $remote_destination ) ) 1143 if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) 1144 return new WP_Error( 'mkdir_failed', $this->strings['mkdir_failed'], $remote_destination ); 1145 1136 1146 foreach ( $language_updates as $language_update ) { 1137 1147 … … 1454 1464 1455 1465 /** 1466 * Check for GIT/SVN checkouts. 1467 */ 1468 function is_vcs_checkout( $context ) { 1469 $stop_dirs = array( 1470 ABSPATH, 1471 untrailingslashit( $context ), 1472 ); 1473 if ( ! file_exists( ABSPATH . '/wp-config.php' ) ) // wp-config.php up one folder in a deployment situation 1474 $stop_dirs[] = dirname( ABSPATH ); 1475 1476 $checkout = false; 1477 foreach ( array_unique( $stop_dirs ) as $dir ) { 1478 if ( file_exists( $dir . '/.svn' ) || file_exists( $dir . '/.git' ) ) { 1479 $checkout = true; 1480 break; 1481 } 1482 } 1483 return apply_filters( 'auto_upgrade_is_vcs_checkout', $checkout, $context ); 1484 } 1485 1486 /** 1456 1487 * Tests to see if we should upgrade a specific item, does not test to see if we CAN update the item. 1457 1488 */ … … 1461 1492 return false; 1462 1493 1463 // ..and also check for GIT/SVN checkouts 1464 if ( ! apply_filters( 'auto_upgrade_ignore_checkout_status', false ) ) { 1465 $stop_dirs = array( 1466 ABSPATH, 1467 untrailingslashit( $context ), 1468 ); 1469 if ( ! file_exists( ABSPATH . '/wp-config.php' ) ) // wp-config.php up one folder in a deployment situation 1470 $stop_dirs[] = dirname( ABSPATH ); 1471 foreach ( array_unique( $stop_dirs ) as $dir ) { 1472 if ( file_exists( $dir . '/.svn' ) || file_exists( $dir . '/.git' ) ) 1473 return false; 1474 } 1475 } 1494 if ( self::is_vcs_checkout( $context ) ) 1495 return false; 1476 1496 1477 1497 // Next up, do we actually have it enabled for this type of update? … … 1540 1560 case 'language': 1541 1561 $upgrader = new Language_Pack_Upgrader( $skin ); 1542 $context = WP_ LANG_DIR;1562 $context = WP_CONTENT_DIR; // WP_LANG_DIR; 1543 1563 break; 1544 1564 } 1545 1565 1546 1566 // Determine if we can perform this upgrade or not 1547 if ( ! self::should_auto_update( $type, $item, $context ) 1567 if ( ! self::should_auto_update( $type, $item, $context ) || ! self::can_auto_update( $context, $skin ) ) 1548 1568 return false; 1549 1569 … … 1619 1639 self::$upgrade_results[ $type ][] = (object) array( 1620 1640 'item' => $item, 1621 'result' => ! is_wp_error( $upgrade_result ) &&$upgrade_result,1641 'result' => $upgrade_result, 1622 1642 'name' => $item_name, 1623 1643 'messages' => $skin->get_upgrade_messages() … … 1730 1750 $upgrade_count += count( $upgrades ); 1731 1751 1732 $subject = sprintf( '[%s] %s updates have finished', get_bloginfo( 'name' ), $upgrade_count ); 1733 1734 $body = ''; 1752 $body = array(); 1753 $failures = 0; 1754 1755 // Core 1735 1756 if ( isset( self::$upgrade_results['core'] ) ) { 1736 1757 $result = self::$upgrade_results['core'][0]; 1737 if ( $result->result && ! is_wp_error( $result->result ) ) 1738 $body[] = sprintf( __( 'WordPress was successfully updated to %s' ), $result->name ); 1739 else 1740 $body[] = sprintf( __( 'WordPress unsuccessfully attempted to update to %s' ), $result->name ); 1741 } 1742 1743 // Plugins 1744 if ( isset( self::$upgrade_results['plugin'] ) ) { 1745 $success_plugins = wp_list_filter( self::$upgrade_results['plugin'], array( 'result' => true ) ); 1746 1747 if ( $success_plugins ) 1748 $body[] = sprintf( _n( 'The following plugin was successfully updated: %s', 'The following plugins were successfully updated: %s', count( $success_plugins ) ), implode( ', ', wp_list_pluck( $success_plugins, 'name' ) ) ); 1749 if ( $success_plugins != self::$upgrade_results['plugin'] ) { 1758 if ( $result->result && ! is_wp_error( $result->result ) ) { 1759 $body[] = sprintf( 'SUCCESS: WordPress was successfully updated to %s', $result->name ); 1760 } else { 1761 $body[] = sprintf( 'FAILED: WordPress failed to update to %s', $result->name ); 1762 $failures++; 1763 } 1764 $body[] = ''; 1765 } 1766 1767 // Plugins, Themes, Languages 1768 foreach ( array( 'plugin', 'theme', 'language' ) as $type ) { 1769 if ( ! isset( self::$upgrade_results[ $type ] ) ) 1770 continue; 1771 $success_items = wp_list_filter( self::$upgrade_results[ $type ], array( 'result' => true ) ); 1772 if ( $success_items ) { 1773 $body[] = "The following {$type}s were successfully updated:"; 1774 foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) 1775 $body[] = ' * SUCCESS: ' . $name; 1776 } 1777 if ( $success_items != self::$upgrade_results[ $type ] ) { 1750 1778 // Failed updates 1751 $failed_plugins = array(); 1752 foreach ( self::$upgrade_results['plugin'] as $plugin ) { 1753 if ( ! $plugin->result || is_wp_error( $plugin->result ) ) 1754 $failed_plugins[] = $plugin; 1779 $body[] = "The following {$type}s failed to update:"; 1780 foreach ( self::$upgrade_results[ $type ] as $item ) { 1781 if ( ! $item->result || is_wp_error( $item->result ) ) { 1782 $body[] = ' * FAILED: ' . $item->name; 1783 $failures++; 1784 } 1755 1785 } 1756 $body[] = sprintf( _n( 'The following plugin failed to successfully update: %s', 'The following plugins failed to successfully update: %s', count( $success_plugins ) ), implode( ', ', wp_list_pluck( $failed_plugins, 'name' ) ) );1757 1786 } 1758 } 1759 1760 // Themes 1761 if ( isset( self::$upgrade_results['theme'] ) ) { 1762 $success_themes = wp_list_filter( self::$upgrade_results['theme'], array( 'result' => true ) ); 1763 1764 if ( $success_themes ) 1765 $body[] = sprintf( _n( 'The following theme was successfully updated: %s', 'The following themes were successfully updated: %s', count( $success_themes ) ), implode( ', ', wp_list_pluck( $success_themes, 'name' ) ) ); 1766 if ( $success_themes != self::$upgrade_results['theme'] ) { 1767 // Failed updates 1768 $failed_themes = array(); 1769 foreach ( self::$upgrade_results['theme'] as $theme ) { 1770 if ( ! $theme->result || is_wp_error( $theme->result ) ) 1771 $failed_themes[] = $theme; 1772 } 1773 $body[] = sprintf( _n( 'The following theme failed to successfully update: %s', 'The following themes failed to successfully update: %s', count( $failed_themes ) ), implode( ', ', wp_list_pluck( $failed_themes, 'name' ) ) ); 1774 } 1775 } 1776 1777 // Languages 1778 if ( isset( self::$upgrade_results['language'] ) ) { 1779 $success_languages = wp_list_filter( self::$upgrade_results['language'], array( 'result' => true ) ); 1780 1781 if ( $success_languages ) 1782 $body[] = sprintf( _n( 'The following language file was successfully updated: %s', 'The following language files were successfully updated: %s', count( $success_languages ) ), implode( ', ', wp_list_pluck( $success_languages, 'name' ) ) ); 1783 if ( $success_languages != self::$upgrade_results['language'] ) { 1784 // Failed updates 1785 $failed_languages = array(); 1786 foreach ( self::$upgrade_results['language'] as $language ) { 1787 if ( ! $language->result || is_wp_error( $language->result ) ) 1788 $failed_languages[] = $language; 1789 } 1790 $body[] = sprintf( _n( 'The following language file failed to successfully update: %s', 'The following language files failed to successfully update: %s', count( $failed_languages ) ), implode( ', ', wp_list_pluck( $failed_languages, 'name' ) ) ); 1791 } 1792 } 1793 1787 $body[] = ''; 1788 } 1789 1790 if ( $failures ) { 1791 $body[] = ''; 1792 $body[] = 'BETA TESTING?'; 1793 $body[] = '============='; 1794 $body[] = ''; 1795 $body[] = 'If you think these failures might be due to a bug in WordPress 3.7, could you report it?'; 1796 $body[] = ' * Open a thread in the support forums: http://wordpress.org/support/forum/alphabeta'; 1797 $body[] = " * Or, if you're comfortable writing a bug report: http://core.trac.wordpress.org/"; 1798 $body[] = ''; 1799 $body[] = 'Thanks! -- The WordPress Team'; 1800 $body[] = ''; 1801 $subject = sprintf( '[%s] There were failures during background updates', get_bloginfo( 'name' ) ); 1802 } else { 1803 $subject = sprintf( '[%s] Background updates have finished', get_bloginfo( 'name' ) ); 1804 } 1805 1806 $body[] = 'UPGRADE LOG'; 1807 $body[] = '==========='; 1794 1808 $body[] = ''; 1795 $body[] = __( 'Below is the upgrade logs for update performed' );1796 1809 1797 1810 foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) { … … 1800 1813 foreach ( self::$upgrade_results[ $type ] as $upgrade ) { 1801 1814 $body[] = $upgrade->name; 1802 $body[] = str_repeat( ' =', strlen( $upgrade->name ) );1815 $body[] = str_repeat( '-', strlen( $upgrade->name ) ); 1803 1816 foreach ( $upgrade->messages as $message ) 1804 $body[] = " " . html_entity_decode( $message ); 1817 $body[] = " " . html_entity_decode( str_replace( '…', '...', $message ) ); 1818 if ( is_wp_error( $upgrade->result ) ) 1819 $body[] = ' Error: [' . $upgrade->result->get_error_code() . '] ' . $upgrade->result->get_error_message(); 1805 1820 $body[] = ''; 1806 1821 } 1807 1822 } 1808 1823 1809 //echo "<h1>$subject</h1>"; 1810 //echo '<pre>' . implode( "\n", $body ) . '</pre>'; 1811 1812 wp_mail( 1813 get_site_option( 'admin_email' ), 1814 $subject, 1815 implode( "\n", $body ) 1816 ); 1817 } 1818 1824 //echo "<h1>\n$subject\n</h1>\n"; 1825 //echo "<pre>\n" . implode( "\n", $body ) . "\n</pre>"; 1826 1827 wp_mail( get_site_option( 'admin_email' ), $subject, implode( "\n", $body ) ); 1828 } 1819 1829 }
Note: See TracChangeset
for help on using the changeset viewer.