<!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>[25835] trunk/src: In automatic background updates, standardize on 'update'.</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/25835">25835</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2013-10-17 23:20:56 +0000 (Thu, 17 Oct 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>In automatic background updates, standardize on 'update'.
New, final filter names:
* auto_update_{$type} (plugin, theme, core, language)
* automatic_updates_is_vcs_checkout
* automatic_updates_disabled
New class name is WP_Automatic_Updater. Method names include update() and should_update().
see <a href="http://core.trac.wordpress.org/ticket/22704">#22704</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminaboutphp">trunk/src/wp-admin/about.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpupgraderphp">trunk/src/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunksrcwpadminincludesupdatephp">trunk/src/wp-admin/includes/update.php</a></li>
<li><a href="#trunksrcwpadminupdatecorephp">trunk/src/wp-admin/update-core.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminaboutphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/about.php (25834 => 25835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/about.php 2013-10-17 20:29:12 UTC (rev 25834)
+++ trunk/src/wp-admin/about.php 2013-10-17 23:20:56 UTC (rev 25835)
</span><span class="lines">@@ -44,14 +44,14 @@
</span><span class="cx"> $can_auto_update = wp_http_supports( 'ssl' );
</span><span class="cx"> if ( $can_auto_update ) {
</span><span class="cx"> require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
</span><del>- $upgrader = new WP_Automatic_Upgrader;
</del><ins>+ $upgrader = new WP_Automatic_Updater;
</ins><span class="cx"> $future_minor_update = (object) array(
</span><span class="cx"> 'current' => $wp_version . '.1-about.php',
</span><span class="cx"> 'version' => $wp_version . '.1-about.php',
</span><span class="cx"> 'php_version' => $required_php_version,
</span><span class="cx"> 'mysql_version' => $required_mysql_version,
</span><span class="cx"> );
</span><del>- $can_auto_update = $upgrader->should_upgrade( 'core', $future_minor_update, ABSPATH );
</del><ins>+ $can_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
</ins><span class="cx"> }
</span><span class="cx"> if ( $can_auto_update ) : ?>
</span><span class="cx"> <p><?php _e( '→ This site <strong>is</strong> able to apply these updates automatically. Cool!' ); ?></p>
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/class-wp-upgrader.php (25834 => 25835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/class-wp-upgrader.php 2013-10-17 20:29:12 UTC (rev 25834)
+++ trunk/src/wp-admin/includes/class-wp-upgrader.php 2013-10-17 23:20:56 UTC (rev 25835)
</span><span class="lines">@@ -1402,7 +1402,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Determines if this WordPress Core version should update to $offered_ver or not
</span><del>- static function should_upgrade_to_version( $offered_ver /* x.y.z */ ) {
</del><ins>+ static function should_update_to_version( $offered_ver /* x.y.z */ ) {
</ins><span class="cx"> include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
</span><span class="cx">
</span><span class="cx"> $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
</span><span class="lines">@@ -1551,11 +1551,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * WordPress automatic background upgrader.
</del><ins>+ * WordPress automatic background updater.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.7.0
</span><span class="cx"> */
</span><del>-class WP_Automatic_Upgrader {
</del><ins>+class WP_Automatic_Updater {
</ins><span class="cx">
</span><span class="cx"> protected $update_results = array();
</span><span class="cx">
</span><span class="lines">@@ -1570,7 +1570,7 @@
</span><span class="cx"> // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters.
</span><span class="cx"> $disabled = defined( 'AUTOMATIC_UPDATES_DISABLED' ) && AUTOMATIC_UPDATES_DISABLED;
</span><span class="cx">
</span><del>- return apply_filters( 'auto_upgrader_disabled', $disabled );
</del><ins>+ return apply_filters( 'automatic_updates_disabled', $disabled );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1600,17 +1600,17 @@
</span><span class="cx"> break 2;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- return apply_filters( 'auto_upgrade_is_vcs_checkout', $checkout, $context );
</del><ins>+ return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Tests to see if we can and should upgrade a specific item.
</del><ins>+ * Tests to see if we can and should update a specific item.
</ins><span class="cx"> */
</span><del>- function should_upgrade( $type, $item, $context ) {
</del><ins>+ function should_update( $type, $item, $context ) {
</ins><span class="cx"> if ( $this->is_disabled() )
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- // Checks to see if WP_Filesystem is set up to allow unattended upgrades.
</del><ins>+ // Checks to see if WP_Filesystem is set up to allow unattended updates.
</ins><span class="cx"> $skin = new Automatic_Upgrader_Skin;
</span><span class="cx"> if ( ! $skin->request_filesystem_credentials( false, $context ) )
</span><span class="cx"> return false;
</span><span class="lines">@@ -1618,24 +1618,15 @@
</span><span class="cx"> if ( $this->is_vcs_checkout( $context ) )
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- // Next up, do we actually have it enabled for this type of update?
- switch ( $type ) {
- case 'language':
- $upgrade = ! empty( $item->autoupdate );
- break;
- case 'core':
- $upgrade = Core_Upgrader::should_upgrade_to_version( $item->current );
- break;
- default:
- case 'plugin':
- case 'theme':
- $upgrade = false;
- break;
- }
</del><ins>+ // Next up, is this an item we can update?
+ if ( 'core' == $type )
+ $update = Core_Upgrader::should_update_to_version( $item->current );
+ else
+ $update = ! empty( $item->autoupdate );
</ins><span class="cx">
</span><span class="cx"> // And does the user / plugins want it?
</span><del>- // Plugins may filter on 'auto_upgrade_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes
- if ( ! apply_filters( 'auto_upgrade_' . $type, $upgrade, $item ) )
</del><ins>+ // Plugins may filter on 'auto_update_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes
+ if ( ! apply_filters( 'auto_update_' . $type, $update, $item ) )
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> // If it's a core update, are we actually compatible with its requirements?
</span><span class="lines">@@ -1655,13 +1646,13 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- function upgrade( $type, $item ) {
</del><ins>+ function update( $type, $item ) {
</ins><span class="cx">
</span><del>- $skin = new Automatic_Upgrader_Skin();
</del><ins>+ $skin = new Automatic_Upgrader_Skin;
</ins><span class="cx">
</span><span class="cx"> switch ( $type ) {
</span><span class="cx"> case 'core':
</span><del>- // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter
</del><ins>+ // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter.
</ins><span class="cx"> add_filter( 'update_feedback', array( $skin, 'feedback' ) );
</span><span class="cx"> $upgrader = new Core_Upgrader( $skin );
</span><span class="cx"> $context = ABSPATH;
</span><span class="lines">@@ -1680,8 +1671,8 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Determine whether we can and should perform this upgrade.
- if ( ! $this->should_upgrade( $type, $item, $context ) )
</del><ins>+ // Determine whether we can and should perform this update.
+ if ( ! $this->should_update( $type, $item, $context ) )
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> switch ( $type ) {
</span><span class="lines">@@ -1733,7 +1724,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Kicks off a upgrade request for each item in the upgrade "queue"
</del><ins>+ * Kicks off a update request for each item in the update "queue".
</ins><span class="cx"> */
</span><span class="cx"> function run() {
</span><span class="cx"> global $wpdb;
</span><span class="lines">@@ -1741,7 +1732,7 @@
</span><span class="cx"> if ( ! is_main_network() || ! is_main_site() )
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- $lock_name = 'auto_upgrader.lock';
</del><ins>+ $lock_name = 'auto_updater.lock';
</ins><span class="cx">
</span><span class="cx"> // Try to lock
</span><span class="cx"> $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
</span><span class="lines">@@ -1772,7 +1763,7 @@
</span><span class="cx"> $plugin_updates = get_site_transient( 'update_plugins' );
</span><span class="cx"> if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
</span><span class="cx"> foreach ( array_keys( $plugin_updates->response ) as $plugin ) {
</span><del>- $this->upgrade( 'plugin', $plugin );
</del><ins>+ $this->update( 'plugin', $plugin );
</ins><span class="cx"> }
</span><span class="cx"> // Force refresh of plugin update information
</span><span class="cx"> wp_clean_plugins_cache();
</span><span class="lines">@@ -1783,13 +1774,13 @@
</span><span class="cx"> $theme_updates = get_site_transient( 'update_themes' );
</span><span class="cx"> if ( $theme_updates && !empty( $theme_updates->response ) ) {
</span><span class="cx"> foreach ( array_keys( $theme_updates->response ) as $theme ) {
</span><del>- $this->upgrade( 'theme', $theme );
</del><ins>+ $this->update( 'theme', $theme );
</ins><span class="cx"> }
</span><span class="cx"> // Force refresh of theme update information
</span><span class="cx"> wp_clean_themes_cache();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Next, Process any core upgrade
</del><ins>+ // Next, Process any core update
</ins><span class="cx"> wp_version_check(); // Check for Core updates
</span><span class="cx"> $extra_update_stats = array();
</span><span class="cx"> $core_update = find_core_auto_update();
</span><span class="lines">@@ -1797,7 +1788,7 @@
</span><span class="cx"> if ( $core_update ) {
</span><span class="cx"> $start_time = time();
</span><span class="cx">
</span><del>- $core_update_result = $this->upgrade( 'core', $core_update );
</del><ins>+ $core_update_result = $this->update( 'core', $core_update );
</ins><span class="cx"> delete_site_transient( 'update_core' );
</span><span class="cx">
</span><span class="cx"> $extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true;
</span><span class="lines">@@ -1826,7 +1817,7 @@
</span><span class="cx"> $language_updates = wp_get_translation_updates();
</span><span class="cx"> if ( $language_updates ) {
</span><span class="cx"> foreach ( $language_updates as $update ) {
</span><del>- $this->upgrade( 'language', $update );
</del><ins>+ $this->update( 'language', $update );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Clear existing caches
</span><span class="lines">@@ -1850,9 +1841,9 @@
</span><span class="cx"> if ( empty( $this->update_results ) )
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- $upgrade_count = 0;
- foreach ( $this->update_results as $type => $upgrades )
- $upgrade_count += count( $upgrades );
</del><ins>+ $update_count = 0;
+ foreach ( $this->update_results as $type => $updates )
+ $update_count += count( $updates );
</ins><span class="cx">
</span><span class="cx"> $body = array();
</span><span class="cx"> $failures = 0;
</span><span class="lines">@@ -1910,20 +1901,20 @@
</span><span class="cx"> $subject = sprintf( '[%s] Background updates have finished', get_bloginfo( 'name' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><del>- $body[] = 'UPGRADE LOG';
- $body[] = '===========';
</del><ins>+ $body[] = 'UPDATE LOG';
+ $body[] = '==========';
</ins><span class="cx"> $body[] = '';
</span><span class="cx">
</span><span class="cx"> foreach ( array( 'core', 'plugin', 'theme', 'language' ) as $type ) {
</span><span class="cx"> if ( ! isset( $this->update_results[ $type ] ) )
</span><span class="cx"> continue;
</span><del>- foreach ( $this->update_results[ $type ] as $upgrade ) {
- $body[] = $upgrade->name;
- $body[] = str_repeat( '-', strlen( $upgrade->name ) );
- foreach ( $upgrade->messages as $message )
</del><ins>+ foreach ( $this->update_results[ $type ] as $update ) {
+ $body[] = $update->name;
+ $body[] = str_repeat( '-', strlen( $update->name ) );
+ foreach ( $update->messages as $message )
</ins><span class="cx"> $body[] = " " . html_entity_decode( str_replace( '…', '...', $message ) );
</span><del>- if ( is_wp_error( $upgrade->result ) )
- $body[] = ' Error: [' . $upgrade->result->get_error_code() . '] ' . $upgrade->result->get_error_message();
</del><ins>+ if ( is_wp_error( $update->result ) )
+ $body[] = ' Error: [' . $update->result->get_error_code() . '] ' . $update->result->get_error_message();
</ins><span class="cx"> $body[] = '';
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/update.php (25834 => 25835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/update.php 2013-10-17 20:29:12 UTC (rev 25834)
+++ trunk/src/wp-admin/includes/update.php 2013-10-17 23:20:56 UTC (rev 25835)
</span><span class="lines">@@ -77,12 +77,12 @@
</span><span class="cx"> include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
</span><span class="cx">
</span><span class="cx"> $auto_update = false;
</span><del>- $upgrader = new WP_Automatic_Upgrader;
</del><ins>+ $upgrader = new WP_Automatic_Updater;
</ins><span class="cx"> foreach ( $updates->updates as $update ) {
</span><span class="cx"> if ( 'autoupdate' != $update->response )
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- if ( ! $upgrader->should_upgrade( 'core', $update, ABSPATH ) )
</del><ins>+ if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) )
</ins><span class="cx"> continue;
</span><span class="cx">
</span><span class="cx"> if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) )
</span></span></pre></div>
<a id="trunksrcwpadminupdatecorephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/update-core.php (25834 => 25835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/update-core.php 2013-10-17 20:29:12 UTC (rev 25834)
+++ trunk/src/wp-admin/update-core.php 2013-10-17 23:20:56 UTC (rev 25835)
</span><span class="lines">@@ -148,14 +148,14 @@
</span><span class="cx">
</span><span class="cx"> if ( wp_http_supports( 'ssl' ) ) {
</span><span class="cx"> require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
</span><del>- $upgrader = new WP_Automatic_Upgrader;
</del><ins>+ $upgrader = new WP_Automatic_Updater;
</ins><span class="cx"> $future_minor_update = (object) array(
</span><span class="cx"> 'current' => $wp_version . '.1-update-core.php',
</span><span class="cx"> 'version' => $wp_version . '.1-update-core.php',
</span><span class="cx"> 'php_version' => $required_php_version,
</span><span class="cx"> 'mysql_version' => $required_mysql_version,
</span><span class="cx"> );
</span><del>- $should_auto_update = $upgrader->should_upgrade( 'core', $future_minor_update, ABSPATH );
</del><ins>+ $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
</ins><span class="cx"> if ( $should_auto_update )
</span><span class="cx"> echo ' ' . __( 'Future security updates will be applied automatically.' );
</span><span class="cx"> }
</span><span class="lines">@@ -172,8 +172,8 @@
</span><span class="cx">
</span><span class="cx"> if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
</span><span class="cx"> require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
</span><del>- $upgrader = new WP_Automatic_Upgrader;
- if ( wp_http_supports( 'ssl' ) && $upgrader->should_upgrade( 'core', $updates[0], ABSPATH ) )
</del><ins>+ $upgrader = new WP_Automatic_Updater;
+ if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) )
</ins><span class="cx"> 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>';
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/update.php (25834 => 25835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/update.php 2013-10-17 20:29:12 UTC (rev 25834)
+++ trunk/src/wp-includes/update.php 2013-10-17 23:20:56 UTC (rev 25835)
</span><span class="lines">@@ -414,7 +414,7 @@
</span><span class="cx"> include_once ABSPATH . '/wp-admin/includes/admin.php';
</span><span class="cx"> include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
</span><span class="cx">
</span><del>- $upgrader = new WP_Automatic_Upgrader;
</del><ins>+ $upgrader = new WP_Automatic_Updater;
</ins><span class="cx"> if ( $upgrader->is_disabled() )
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>