Make WordPress Core

Changeset 25633


Ignore:
Timestamp:
09/27/2013 11:20:08 PM (13 years ago)
Author:
nacin
Message:

Changes to automatic background updates in preparation for Beta 1.

  • Show a notice for beta testers on update-core.php explaining the status of their install. Three possibilities: auto updates are enabled, auto updates are disabled because the install doesn't support SSL HTTP requests, and auto updates are disabled because it is a VCS checkout.
  • Improve the output of the email, for maximum debugging potential. Failures are clearly labeled and the email leads testers to the support forums and Trac.
  • Try to create wp-content/languages in the upgrader if it doesn't exist. Our mkdir isn't recursive, so trying to create wp-content/languages/plugins could fail.
  • Abstract out version control checkout determination into a public method. The filter is now auto_upgrade_is_vcs_checkout, still subject to change.

see #22704.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25599 r25633  
    11021102                if ( $update )
    11031103                        $update = array( $update );
    1104                 return $this->bulk_upgrade( $update );
     1104                $results = $this->bulk_upgrade( $update );
     1105                return $results[0];
    11051106        }
    11061107
    11071108        function bulk_upgrade( $language_updates = array() ) {
     1109                global $wp_filesystem;
    11081110
    11091111                $this->init();
     
    11341136                $this->update_count = count( $language_updates );
    11351137                $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
    11361146                foreach ( $language_updates as $language_update ) {
    11371147
     
    14541464
    14551465        /**
     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        /**
    14561487         * Tests to see if we should upgrade a specific item, does not test to see if we CAN update the item.
    14571488         */
     
    14611492                        return false;
    14621493
    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;
    14761496
    14771497                // Next up, do we actually have it enabled for this type of update?
     
    15401560                        case 'language':
    15411561                                $upgrader = new Language_Pack_Upgrader( $skin );
    1542                                 $context  = WP_LANG_DIR;
     1562                                $context  = WP_CONTENT_DIR; // WP_LANG_DIR;
    15431563                                break;
    15441564                }
    15451565
    15461566                // Determine if we can perform this upgrade or not
    1547                 if ( ! self::should_auto_update( $type, $item, $context )  || ! self::can_auto_update( $context, $skin ) )
     1567                if ( ! self::should_auto_update( $type, $item, $context ) || ! self::can_auto_update( $context, $skin ) )
    15481568                        return false;
    15491569
     
    16191639                self::$upgrade_results[ $type ][] = (object) array(
    16201640                        'item'     => $item,
    1621                         'result'   => ! is_wp_error( $upgrade_result ) && $upgrade_result,
     1641                        'result'   => $upgrade_result,
    16221642                        'name'     => $item_name,
    16231643                        'messages' => $skin->get_upgrade_messages()
     
    17301750                        $upgrade_count += count( $upgrades );
    17311751
    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
    17351756                if ( isset( self::$upgrade_results['core'] ) ) {
    17361757                        $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 ] ) {
    17501778                                // 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                                        }
    17551785                                }
    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' ) ) );
    17571786                        }
    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[] = '===========';
    17941808                $body[] = '';
    1795                 $body[] = __( 'Below is the upgrade logs for update performed' );
    17961809
    17971810                foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) {
     
    18001813                        foreach ( self::$upgrade_results[ $type ] as $upgrade ) {
    18011814                                $body[] = $upgrade->name;
    1802                                 $body[] = str_repeat( '=', strlen( $upgrade->name ) );
     1815                                $body[] = str_repeat( '-', strlen( $upgrade->name ) );
    18031816                                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();
    18051820                                $body[] = '';
    18061821                        }
    18071822                }
    18081823
    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        }
    18191829}
  • trunk/src/wp-admin/update-core.php

    r25616 r25633  
    154154        }
    155155
     156        // This is temporary, for the WordPress 3.7 beta period.
     157        if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
     158                require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     159                $ssl_support = wp_http_supports( 'ssl' );
     160                $should_auto_update = WP_Automatic_Upgrader::should_auto_update( 'core', $updates[0], ABSPATH );
     161                if ( $ssl_support && $should_auto_update ) {
     162                        echo '<div class="updated inline"><p><strong>BETA TESTERS: This install will receive daily auto updates to future beta versions.</strong>';
     163                        if ( get_locale() !== 'en_US' )
     164                                echo ' Translations of importers and default themes will also be updated.';
     165                        echo '</p><p>You will receive an email with debugging output after each update. If something goes wrong, please <a href="http://wordpress.org/support/forum/alphabeta">post in the support forums</a> or <a href="https://core.trac.wordpress.org/">open a bug report</a>.</div>';
     166                } elseif ( ! $ssl_support ) {
     167                        echo '<div class="error inline"><p><strong>BETA TESTERS:</strong> Your server does not support HTTP requests over SSL. This install will not receive auto updates.</p></div>';
     168                } elseif ( WP_Automatic_Upgrader::is_vcs_checkout( ABSPATH ) ) {
     169                        echo '<div class="error inline"><p><strong>BETA TESTERS:</strong> This install uses version control (SVN or Git) and thus will not receive auto updates. Try a separate install of WordPress with the <a href="http://wordpress.org/plugins/wordpress-beta-tester/">Beta Tester</a> plugin set to bleeding edge.</p></div>';
     170                }
     171        }
     172
    156173        echo '<ul class="core-updates">';
    157174        $alternate = true;
  • trunk/src/wp-includes/version.php

    r25448 r25633  
    55 * @global string $wp_version
    66 */
    7 $wp_version = '3.7-alpha-25343';
     7$wp_version = '3.7-alpha-25633';
    88
    99/**
Note: See TracChangeset for help on using the changeset viewer.