<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[25633] trunk/src: Changes to automatic background updates in preparation for Beta 1.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/25633">25633</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2013-09-27 23:20:08 +0000 (Fri, 27 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/22704">#22704</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpupgraderphp">trunk/src/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunksrcwpadminupdatecorephp">trunk/src/wp-admin/update-core.php</a></li>
<li><a href="#trunksrcwpincludesversionphp">trunk/src/wp-includes/version.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/class-wp-upgrader.php (25632 => 25633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-upgrader.php        2013-09-27 17:33:36 UTC (rev 25632)
+++ trunk/src/wp-admin/includes/class-wp-upgrader.php   2013-09-27 23:20:08 UTC (rev 25633)
</span><span class="lines">@@ -1101,10 +1101,12 @@
</span><span class="cx">  function upgrade( $update = false ) {
</span><span class="cx">          if ( $update )
</span><span class="cx">                  $update = array( $update );
</span><del>-               return $this->bulk_upgrade( $update );
</del><ins>+                $results = $this->bulk_upgrade( $update );
+               return $results[0];
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  function bulk_upgrade( $language_updates = array() ) {
</span><ins>+               global $wp_filesystem;
</ins><span class="cx"> 
</span><span class="cx">          $this->init();
</span><span class="cx">          $this->upgrade_strings();
</span><span class="lines">@@ -1133,6 +1135,14 @@
</span><span class="cx"> 
</span><span class="cx">          $this->update_count = count( $language_updates );
</span><span class="cx">          $this->update_current = 0;
</span><ins>+
+               // The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists,
+               // as we then may need to create a /plugins or /themes directory inside of it.
+               $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
+               if ( ! $wp_filesystem->exists( $remote_destination ) )
+                       if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
+                               return new WP_Error( 'mkdir_failed', $this->strings['mkdir_failed'], $remote_destination );
+
</ins><span class="cx">           foreach ( $language_updates as $language_update ) {
</span><span class="cx"> 
</span><span class="cx">                  $destination = WP_LANG_DIR;
</span><span class="lines">@@ -1453,6 +1463,27 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><ins>+        * Check for GIT/SVN checkouts.
+        */
+       function is_vcs_checkout( $context ) {
+               $stop_dirs = array(
+                       ABSPATH,
+                       untrailingslashit( $context ),
+               );
+               if ( ! file_exists( ABSPATH . '/wp-config.php' ) ) // wp-config.php up one folder in a deployment situation
+                       $stop_dirs[] = dirname( ABSPATH );
+
+               $checkout = false;
+               foreach ( array_unique( $stop_dirs ) as $dir ) {
+                       if ( file_exists( $dir . '/.svn' ) || file_exists( $dir . '/.git' ) ) {
+                               $checkout = true;
+                               break;
+                       }
+               }
+               return apply_filters( 'auto_upgrade_is_vcs_checkout', $checkout, $context );
+       }
+
+       /**
</ins><span class="cx">    * Tests to see if we should upgrade a specific item, does not test to see if we CAN update the item.
</span><span class="cx">   */
</span><span class="cx">  static function should_auto_update( $type, $item, $context ) {
</span><span class="lines">@@ -1460,19 +1491,8 @@
</span><span class="cx">          if ( self::upgrader_disabled() )
</span><span class="cx">                  return false;
</span><span class="cx"> 
</span><del>-               // ..and also check for GIT/SVN checkouts
-               if ( ! apply_filters( 'auto_upgrade_ignore_checkout_status', false ) ) {
-                       $stop_dirs = array(
-                               ABSPATH,
-                               untrailingslashit( $context ),
-                       );
-                       if ( ! file_exists( ABSPATH . '/wp-config.php' ) ) // wp-config.php up one folder in a deployment situation
-                               $stop_dirs[] = dirname( ABSPATH );
-                       foreach ( array_unique( $stop_dirs ) as $dir ) {
-                               if ( file_exists( $dir . '/.svn' ) || file_exists( $dir . '/.git' ) )
-                                       return false;
-                       }
-               }
</del><ins>+                if ( self::is_vcs_checkout( $context ) )
+                       return false;
</ins><span class="cx"> 
</span><span class="cx">          // Next up, do we actually have it enabled for this type of update?
</span><span class="cx">          switch ( $type ) {
</span><span class="lines">@@ -1539,12 +1559,12 @@
</span><span class="cx">                          break;
</span><span class="cx">                  case 'language':
</span><span class="cx">                          $upgrader = new Language_Pack_Upgrader( $skin );
</span><del>-                               $context  = WP_LANG_DIR;
</del><ins>+                                $context  = WP_CONTENT_DIR; // WP_LANG_DIR;
</ins><span class="cx">                           break;
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          // Determine if we can perform this upgrade or not
</span><del>-               if ( ! self::should_auto_update( $type, $item, $context )  || ! self::can_auto_update( $context, $skin ) )
</del><ins>+                if ( ! self::should_auto_update( $type, $item, $context ) || ! self::can_auto_update( $context, $skin ) )
</ins><span class="cx">                   return false;
</span><span class="cx"> 
</span><span class="cx">          switch ( $type ) {
</span><span class="lines">@@ -1618,7 +1638,7 @@
</span><span class="cx"> 
</span><span class="cx">          self::$upgrade_results[ $type ][] = (object) array(
</span><span class="cx">                  'item'     => $item,
</span><del>-                       'result'   => ! is_wp_error( $upgrade_result ) && $upgrade_result,
</del><ins>+                        'result'   => $upgrade_result,
</ins><span class="cx">                   'name'     => $item_name,
</span><span class="cx">                  'messages' => $skin->get_upgrade_messages()
</span><span class="cx">          );
</span><span class="lines">@@ -1729,91 +1749,81 @@
</span><span class="cx">          foreach ( self::$upgrade_results as $type => $upgrades )
</span><span class="cx">                  $upgrade_count += count( $upgrades );
</span><span class="cx"> 
</span><del>-               $subject = sprintf( '[%s] %s updates have finished', get_bloginfo( 'name' ), $upgrade_count );
</del><ins>+                $body = array();
+               $failures = 0;
</ins><span class="cx"> 
</span><del>-               $body = '';
</del><ins>+                // Core
</ins><span class="cx">           if ( isset( self::$upgrade_results['core'] ) ) {
</span><span class="cx">                  $result = self::$upgrade_results['core'][0];
</span><del>-                       if ( $result->result && ! is_wp_error( $result->result ) )
-                               $body[] = sprintf( __( 'WordPress was successfully updated to %s' ), $result->name );
-                       else
-                               $body[] = sprintf( __( 'WordPress unsuccessfully attempted to update to %s' ), $result->name );
</del><ins>+                        if ( $result->result && ! is_wp_error( $result->result ) ) {
+                               $body[] = sprintf( 'SUCCESS: WordPress was successfully updated to %s', $result->name );
+                       } else {
+                               $body[] = sprintf( 'FAILED: WordPress failed to update to %s', $result->name );
+                               $failures++;
+                       }
+                       $body[] = '';
</ins><span class="cx">           }
</span><span class="cx"> 
</span><del>-               // Plugins
-               if ( isset( self::$upgrade_results['plugin'] ) ) {
-                       $success_plugins = wp_list_filter( self::$upgrade_results['plugin'], array( 'result' => true ) );
-
-                       if ( $success_plugins )
-                               $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' ) ) );
-                       if ( $success_plugins != self::$upgrade_results['plugin'] ) {
-                               // Failed updates
-                               $failed_plugins = array();
-                               foreach ( self::$upgrade_results['plugin'] as $plugin ) {
-                                       if ( ! $plugin->result || is_wp_error( $plugin->result ) )
-                                               $failed_plugins[] = $plugin;
-                               }
-                               $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' ) ) );
</del><ins>+                // Plugins, Themes, Languages
+               foreach ( array( 'plugin', 'theme', 'language' ) as $type ) {
+                       if ( ! isset( self::$upgrade_results[ $type ] ) )
+                               continue;
+                       $success_items = wp_list_filter( self::$upgrade_results[ $type ], array( 'result' => true ) );
+                       if ( $success_items ) {
+                               $body[] = "The following {$type}s were successfully updated:";
+                               foreach ( wp_list_pluck( $success_items, 'name' ) as $name )
+                                       $body[] = ' * SUCCESS: ' . $name;
</ins><span class="cx">                   }
</span><del>-               }
-
-               // Themes
-               if ( isset( self::$upgrade_results['theme'] ) ) {
-                       $success_themes = wp_list_filter( self::$upgrade_results['theme'], array( 'result' => true ) );
-
-                       if ( $success_themes )
-                               $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' ) ) );
-                       if ( $success_themes != self::$upgrade_results['theme'] ) {
</del><ins>+                        if ( $success_items != self::$upgrade_results[ $type ] ) {
</ins><span class="cx">                           // Failed updates
</span><del>-                               $failed_themes = array();
-                               foreach ( self::$upgrade_results['theme'] as $theme ) {
-                                       if ( ! $theme->result || is_wp_error( $theme->result ) )
-                                               $failed_themes[] = $theme;
</del><ins>+                                $body[] = "The following {$type}s failed to update:";
+                               foreach ( self::$upgrade_results[ $type ] as $item ) {
+                                       if ( ! $item->result || is_wp_error( $item->result ) ) {
+                                               $body[] = ' * FAILED: ' . $item->name;
+                                               $failures++;
+                                       }
</ins><span class="cx">                           }
</span><del>-                               $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' ) ) );
</del><span class="cx">                   }
</span><ins>+                       $body[] = '';
</ins><span class="cx">           }
</span><span class="cx"> 
</span><del>-               // Languages
-               if ( isset( self::$upgrade_results['language'] ) ) {
-                       $success_languages = wp_list_filter( self::$upgrade_results['language'], array( 'result' => true ) );
-
-                       if ( $success_languages )
-                               $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' ) ) );
-                       if ( $success_languages != self::$upgrade_results['language'] ) {
-                               // Failed updates
-                               $failed_languages = array();
-                               foreach ( self::$upgrade_results['language'] as $language ) {
-                                       if ( ! $language->result || is_wp_error( $language->result ) )
-                                               $failed_languages[] = $language;
-                               }
-                               $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' ) ) );
-                       }
</del><ins>+                if ( $failures ) {
+                       $body[] = '';
+                       $body[] = 'BETA TESTING?';
+                       $body[] = '=============';
+                       $body[] = '';
+                       $body[] = 'If you think these failures might be due to a bug in WordPress 3.7, could you report it?';
+                       $body[] = ' * Open a thread in the support forums: http://wordpress.org/support/forum/alphabeta';
+                       $body[] = " * Or, if you're comfortable writing a bug report: http://core.trac.wordpress.org/";
+                       $body[] = '';
+                       $body[] = 'Thanks! -- The WordPress Team';
+                       $body[] = '';
+                       $subject = sprintf( '[%s] There were failures during background updates', get_bloginfo( 'name' ) );
+               } else {
+                       $subject = sprintf( '[%s] Background updates have finished', get_bloginfo( 'name' ) );
</ins><span class="cx">           }
</span><span class="cx"> 
</span><ins>+               $body[] = 'UPGRADE LOG';
+               $body[] = '===========';
</ins><span class="cx">           $body[] = '';
</span><del>-               $body[] = __( 'Below is the upgrade logs for update performed' );
</del><span class="cx"> 
</span><span class="cx">          foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) {
</span><span class="cx">                  if ( ! isset( self::$upgrade_results[ $type ] ) )
</span><span class="cx">                          continue;
</span><span class="cx">                  foreach ( self::$upgrade_results[ $type ] as $upgrade ) {
</span><span class="cx">                          $body[] = $upgrade->name;
</span><del>-                               $body[] = str_repeat( '=', strlen( $upgrade->name ) );
</del><ins>+                                $body[] = str_repeat( '-', strlen( $upgrade->name ) );
</ins><span class="cx">                           foreach ( $upgrade->messages as $message )
</span><del>-                                       $body[] = "  " . html_entity_decode( $message );
</del><ins>+                                        $body[] = "  " . html_entity_decode( str_replace( '&#8230;', '...', $message ) );
+                               if ( is_wp_error( $upgrade->result ) )
+                                       $body[] = '  Error: [' . $upgrade->result->get_error_code() . '] ' . $upgrade->result->get_error_message();
</ins><span class="cx">                           $body[] = '';
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               //echo "<h1>$subject</h1>";
-               //echo '<pre>' . implode( "\n", $body ) . '</pre>';
</del><ins>+                //echo "<h1>\n$subject\n</h1>\n";
+               //echo "<pre>\n" . implode( "\n", $body ) . "\n</pre>";
</ins><span class="cx"> 
</span><del>-               wp_mail(
-                       get_site_option( 'admin_email' ),
-                       $subject,
-                       implode( "\n", $body )
-               );
</del><ins>+                wp_mail( get_site_option( 'admin_email' ), $subject, implode( "\n", $body ) );
</ins><span class="cx">   }
</span><del>-
</del><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcwpadminupdatecorephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/update-core.php (25632 => 25633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/update-core.php       2013-09-27 17:33:36 UTC (rev 25632)
+++ trunk/src/wp-admin/update-core.php  2013-09-27 23:20:08 UTC (rev 25633)
</span><span class="lines">@@ -153,6 +153,23 @@
</span><span class="cx">          echo '</h3>';
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       // This is temporary, for the WordPress 3.7 beta period.
+       if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
+               require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+               $ssl_support = wp_http_supports( 'ssl' );
+               $should_auto_update = WP_Automatic_Upgrader::should_auto_update( 'core', $updates[0], ABSPATH );
+               if ( $ssl_support && $should_auto_update ) {
+                       echo '<div class="updated inline"><p><strong>BETA TESTERS: This install will receive daily auto updates to future beta versions.</strong>';
+                       if ( get_locale() !== 'en_US' )
+                               echo ' Translations of importers and default themes will also be updated.';
+                       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>';
+               } elseif ( ! $ssl_support ) {
+                       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>';
+               } elseif ( WP_Automatic_Upgrader::is_vcs_checkout( ABSPATH ) ) {
+                       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>';
+               }
+       }
+
</ins><span class="cx">   echo '<ul class="core-updates">';
</span><span class="cx">  $alternate = true;
</span><span class="cx">  foreach( (array) $updates as $update ) {
</span></span></pre></div>
<a id="trunksrcwpincludesversionphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/version.php (25632 => 25633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/version.php        2013-09-27 17:33:36 UTC (rev 25632)
+++ trunk/src/wp-includes/version.php   2013-09-27 23:20:08 UTC (rev 25633)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @global string $wp_version
</span><span class="cx">  */
</span><del>-$wp_version = '3.7-alpha-25343';
</del><ins>+$wp_version = '3.7-alpha-25633';
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
</span></span></pre>
</div>
</div>

</body>
</html>