<!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>[12523] trunk:
Check required php and mysql versions in the update response and notify if the server environment does not meet those requirements
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12523">12523</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-12-23 18:35:12 +0000 (Wed, 23 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Check required php and mysql versions in the update response and notify if the server environment does not meet those requirements. fixes <a href="http://trac.wordpress.org/ticket/11562">#11562</a></pre>
<h3>Modified Paths</h3>
<ul>
<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="trunkwpadminupdatecorephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update-core.php (12522 => 12523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update-core.php        2009-12-23 16:44:46 UTC (rev 12522)
+++ trunk/wp-admin/update-core.php        2009-12-23 18:35:12 UTC (rev 12523)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">         wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
</span><span class="cx">
</span><span class="cx"> function list_core_update( $update ) {
</span><del>-        global $wp_local_package;
</del><ins>+        global $wp_local_package, $wpdb;
</ins><span class="cx">         $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
</span><span class="cx">                         $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
</span><span class="cx">         $current = false;
</span><span class="lines">@@ -21,6 +21,9 @@
</span><span class="cx">                 $current = true;
</span><span class="cx">         $submit = __('Upgrade Automatically');
</span><span class="cx">         $form_action = 'update-core.php?action=do-core-upgrade';
</span><ins>+        $php_version = phpversion();
+        $mysql_version = $wpdb->db_version();
+        $show_buttons = true;
</ins><span class="cx">         if ( 'development' == $update->response ) {
</span><span class="cx">                 $message = __('You are using a development version of WordPress. You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:');
</span><span class="cx">                 $download = __('Download nightly build');
</span><span class="lines">@@ -30,7 +33,18 @@
</span><span class="cx">                         $submit = __('Re-install Automatically');
</span><span class="cx">                         $form_action = 'update-core.php?action=do-core-reinstall';
</span><span class="cx">                 } else {
</span><del>-                        $message =         sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
</del><ins>+                        $php_compat = version_compare( $php_version, $update->php_version, '>=' );
+                        $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
+                        if ( !$mysql_compat && !$php_compat )
+                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );
+                        elseif ( !$php_compat )
+                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
+                        elseif ( !$mysql_compat )
+                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
+                        else
+                                $message =         sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
+                        if ( !$mysql_compat || !$php_compat )
+                                $show_buttons = false;
</ins><span class="cx">                 }
</span><span class="cx">                 $download = sprintf(__('Download %s'), $version_string);
</span><span class="cx">         }
</span><span class="lines">@@ -41,10 +55,12 @@
</span><span class="cx">         echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
</span><span class="cx">         wp_nonce_field('upgrade-core');
</span><span class="cx">         echo '<p>';
</span><del>-        echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
</del><span class="cx">         echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
</span><span class="cx">         echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
</span><del>-        echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
</del><ins>+        if ( $show_buttons ) {
+                echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
+                echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
+        }
</ins><span class="cx">         if ( 'en_US' != $update->locale )
</span><span class="cx">                 if ( !isset( $update->dismissed ) || !$update->dismissed )
</span><span class="cx">                         echo '<input id="dismiss" class="button" type="submit" value="' . esc_attr__('Hide this update') . '" name="dismiss" />';
</span></span></pre></div>
<a id="trunkwpincludesupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/update.php (12522 => 12523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/update.php        2009-12-23 16:44:46 UTC (rev 12522)
+++ trunk/wp-includes/update.php        2009-12-23 18:35:12 UTC (rev 12523)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">         else
</span><span class="cx">                 $mysql_version = 'N/A';
</span><span class="cx">         $local_package = isset( $wp_local_package )? $wp_local_package : '';
</span><del>-        $url = "http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
</del><ins>+        $url = "http://api.wordpress.org/core/version-check/1.4/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
</ins><span class="cx">
</span><span class="cx">         $options = array(
</span><span class="cx">                 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
</span><span class="lines">@@ -74,6 +74,10 @@
</span><span class="cx">                         $new_option->current = esc_attr( $returns[3] );
</span><span class="cx">                 if ( isset( $returns[4] ) )
</span><span class="cx">                         $new_option->locale = esc_attr( $returns[4] );
</span><ins>+                if ( isset( $returns[5] ) )
+                        $new_option->php_version = esc_attr( $returns[5] );
+                if ( isset( $returns[6] ) )
+                        $new_option->mysql_version = esc_attr( $returns[6] );
</ins><span class="cx">                 $new_options[] = $new_option;
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>