<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[12157] trunk: Put site into maintenance mode during bulk plugin upgrade.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12157">12157</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-11-09 18:53:21 +0000 (Mon, 09 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Put site into maintenance mode during bulk plugin upgrade. Skip plugin deactivate/activate. Add compatibility info. see <a href="http://trac.wordpress.org/ticket/10973">#10973</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpupgraderphp">trunk/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunkwpadminupdatecorephp">trunk/wp-admin/update-core.php</a></li>
<li><a href="#trunkwpincludesupdatephp">trunk/wp-includes/update.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-upgrader.php (12156 => 12157)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-upgrader.php        2009-11-08 11:05:49 UTC (rev 12156)
+++ trunk/wp-admin/includes/class-wp-upgrader.php        2009-11-09 18:53:21 UTC (rev 12157)
</span><span class="lines">@@ -432,7 +432,7 @@
</span><span class="cx">                                         )
</span><span class="cx">                                 ));
</span><span class="cx">
</span><del>-                //Cleanup our hooks, incase something else does a upgrade on this connection.
</del><ins>+                // Cleanup our hooks, incase something else does a upgrade on this connection.
</ins><span class="cx">                 remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
</span><span class="cx">                 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
</span><span class="cx">
</span><span class="lines">@@ -451,10 +451,19 @@
</span><span class="cx">
</span><span class="cx">                 $current = get_transient( 'update_plugins' );
</span><span class="cx">
</span><del>-                add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
</del><span class="cx">                 add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
</span><span class="cx">
</span><span class="cx">                 $this->skin->header();
</span><ins>+
+                // Connect to the Filesystem first.
+                $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
+                if ( ! $res ) {
+                        $this->skin->footer();
+                        return false;
+                }
+
+                $this->maintenance_mode(true);
+
</ins><span class="cx">                 $all = count($plugins);
</span><span class="cx">                 $i = 1;
</span><span class="cx">                 foreach ( $plugins as $plugin ) {
</span><span class="lines">@@ -492,10 +501,10 @@
</span><span class="cx">                         if ( false === $result )
</span><span class="cx">                                 break;
</span><span class="cx">                 }
</span><ins>+                $this->maintenance_mode(false);
</ins><span class="cx">                 $this->skin->footer();
</span><span class="cx">
</span><del>-                //Cleanup our hooks, incase something else does a upgrade on this connection.
-                remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
</del><ins>+                // Cleanup our hooks, incase something else does a upgrade on this connection.
</ins><span class="cx">                 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
</span><span class="cx">
</span><span class="cx">                 // Force refresh of plugin update information
</span><span class="lines">@@ -899,11 +908,15 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function after() {
</span><ins>+                if ( $this->upgrader->bulk )
+                        return;
+
</ins><span class="cx">                 $this->plugin = $this->upgrader->plugin_info();
</span><span class="cx">                 if( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
</span><span class="cx">                         show_message(__('Attempting reactivation of the plugin'));
</span><span class="cx">                         echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 $update_actions = array(
</span><span class="cx">                         'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
</span><span class="cx">                         'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
</span></span></pre></div>
<a id="trunkwpadminupdatecorephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update-core.php (12156 => 12157)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update-core.php        2009-11-08 11:05:49 UTC (rev 12156)
+++ trunk/wp-admin/update-core.php        2009-11-09 18:53:21 UTC (rev 12157)
</span><span class="lines">@@ -133,6 +133,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function list_plugin_updates() {
</span><ins>+        global $wp_version;
+
+        $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
+
+        require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
</ins><span class="cx">         $plugins = get_plugin_updates();
</span><span class="cx">         if ( empty($plugins) )
</span><span class="cx">                 return;
</span><span class="lines">@@ -160,10 +165,17 @@
</span><span class="cx">         <tbody class="plugins">
</span><span class="cx"> <?php
</span><span class="cx">         foreach ( (array) $plugins as $plugin_file => $plugin_data) {
</span><ins>+                $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
+                if ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
+                        $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
+                        $compat = ' ' . sprintf(__('Compatibility: %1$d%% (%2$d "works" votes out of %3$d total)'), $compat[0], $compat[2], $compat[1]);
+                } else {
+                        $compat = '';
+                }
</ins><span class="cx">                 echo "
</span><span class="cx">         <tr class='active'>
</span><span class="cx">                 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
</span><del>-                <td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You are running version %1$s. Upgrade to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . "</td>
</del><ins>+                <td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You are running version %1$s. Upgrade to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . "</td>
</ins><span class="cx">         </tr>";
</span><span class="cx">         }
</span><span class="cx"> ?>
</span><span class="lines">@@ -300,8 +312,6 @@
</span><span class="cx">         $url = 'update-core.php?action=do-plugin-upgrade&amp;plugins=' . urlencode(join(',', $plugins));
</span><span class="cx">         $title = __('Upgrade Plugins');
</span><span class="cx">         $nonce = 'upgrade-core';
</span><del>-        add_filter('update_plugin_complete_actions', 'no_update_actions');
-
</del><span class="cx">         $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
</span><span class="cx">         $upgrader->bulk_upgrade($plugins);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/update.php (12156 => 12157)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/update.php        2009-11-08 11:05:49 UTC (rev 12156)
+++ trunk/wp-includes/update.php        2009-11-09 18:53:21 UTC (rev 12157)
</span><span class="lines">@@ -314,6 +314,7 @@
</span><span class="cx">
</span><span class="cx"> add_action( 'load-plugins.php', 'wp_update_plugins' );
</span><span class="cx"> add_action( 'load-update.php', 'wp_update_plugins' );
</span><ins>+add_action( 'load-update-core.php', 'wp_update_plugins' );
</ins><span class="cx"> add_action( 'admin_init', '_maybe_update_plugins' );
</span><span class="cx"> add_action( 'wp_update_plugins', 'wp_update_plugins' );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>