<!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>[839] trunk: Fix multisite installation and initialization.</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, #logmsg > ol { margin-left: 0; 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://unit-tests.trac.wordpress.org/changeset/839">839</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-07-01 22:10:46 +0000 (Sun, 01 Jul 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix multisite installation and initialization. The factory should be used instead of any default blogs. see <a href="http://unit-tests.trac.wordpress.org/ticket/100">#100</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbininstallphp">trunk/bin/install.php</a></li>
<li><a href="#trunkbootstrapphp">trunk/bootstrap.php</a></li>
<li><a href="#trunkwptestlibfunctionsphp">trunk/wp-testlib/functions.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkbinmsinstallphp">trunk/bin/ms-install.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/bin/install.php (838 => 839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bin/install.php        2012-07-01 21:42:52 UTC (rev 838)
+++ trunk/bin/install.php        2012-07-01 22:10:46 UTC (rev 839)
</span><span class="lines">@@ -26,36 +26,36 @@
</span><span class="cx"> define( 'WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version' );
</span><span class="cx"> 
</span><span class="cx"> $wpdb-&gt;suppress_errors();
</span><del>-$wpdb-&gt;hide_errors();
</del><span class="cx"> $installed = $wpdb-&gt;get_var( &quot;SELECT option_value FROM $wpdb-&gt;options WHERE option_name = 'siteurl'&quot; );
</span><ins>+$wpdb-&gt;suppress_errors( false );
</ins><span class="cx"> 
</span><del>-if ( $installed &amp;&amp; file_exists( WP_TESTS_VERSION_FILE ) ) {
-        $installed_version_hash = file_get_contents( WP_TESTS_VERSION_FILE );
-        if ( $installed_version_hash == test_version_check_hash() ) {
</del><ins>+$hash = get_option( 'db_version' ) . ' ' . sha1( file_get_contents( $config_file_path ) );
+
+if ( $installed &amp;&amp; file_exists( WP_TESTS_VERSION_FILE ) &amp;&amp; file_get_contents( WP_TESTS_VERSION_FILE ) == $hash )
</ins><span class="cx">                 return;
</span><del>-        }
-}
</del><ins>+
</ins><span class="cx"> $wpdb-&gt;query( 'SET storage_engine = INNODB;' );
</span><span class="cx"> $wpdb-&gt;query( 'DROP DATABASE IF EXISTS '.DB_NAME.&quot;;&quot; );
</span><span class="cx"> $wpdb-&gt;query( 'CREATE DATABASE '.DB_NAME.&quot;;&quot; );
</span><span class="cx"> $wpdb-&gt;select( DB_NAME, $wpdb-&gt;dbh );
</span><span class="cx"> 
</span><span class="cx"> echo &quot;Installing…&quot; . PHP_EOL;
</span><del>-wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, '', 'a' );
</del><ins>+wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
</ins><span class="cx"> 
</span><del>-if ( defined('WP_ALLOW_MULTISITE') &amp;&amp; WP_ALLOW_MULTISITE ) {
-        echo &quot;Installing network…&quot; .PHP_EOL;
</del><ins>+if ( defined( 'WP_TESTS_MULTISITE' ) &amp;&amp; WP_TESTS_MULTISITE ) {
+        echo &quot;Installing network…&quot; . PHP_EOL;
</ins><span class="cx"> 
</span><span class="cx">         define( 'WP_INSTALLING_NETWORK', true );
</span><del>-        //wp_set_wpdb_vars();
-        // We need to create references to ms global tables to enable Network.
</del><ins>+
+        // We need to create references to ms global tables.
</ins><span class="cx">         foreach ( $wpdb-&gt;tables( 'ms_global' ) as $table =&gt; $prefixed_table )
</span><span class="cx">                 $wpdb-&gt;$table = $prefixed_table;
</span><del>-        install_network();
-        $result = populate_network(1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL);
</del><span class="cx"> 
</span><del>-        system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) );
</del><ins>+        $title = WP_TESTS_TITLE . ' Network';
+        $subdomain_install = false;
</ins><span class="cx"> 
</span><ins>+        install_network();
+        populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() );
</del><ins>+file_put_contents( WP_TESTS_VERSION_FILE, $hash );
</ins></span></pre></div>
<a id="trunkbinmsinstallphp"></a>
<div class="delfile"><h4>Deleted: trunk/bin/ms-install.php (838 => 839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bin/ms-install.php        2012-07-01 21:42:52 UTC (rev 838)
+++ trunk/bin/ms-install.php        2012-07-01 22:10:46 UTC (rev 839)
</span><span class="lines">@@ -1,39 +0,0 @@
</span><del>-&lt;?php
-/**
- * Installs additional MU sites for the purpose of the unit-tests
- *
- * @todo Reuse the init/load code in init.php
- */
-error_reporting( E_ALL &amp; ~E_DEPRECATED &amp; ~E_STRICT );
-
-$config_file_path = $argv[1];
-
-require_once $config_file_path;
-
-$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
-$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
-$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
-$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
-
-require_once ABSPATH . '/wp-settings.php';
-
-require_once ABSPATH . '/wp-admin/includes/upgrade.php';
-require_once ABSPATH . '/wp-includes/wp-db.php';
-
-echo &quot;Installing sites…&quot; . PHP_EOL;
-wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, '', 'a' );
-
-if ( defined('WP_ALLOW_MULTISITE') &amp;&amp; WP_ALLOW_MULTISITE ) {
-        $blogs = explode(',', WP_TESTS_BLOGS);
-        foreach ( $blogs as $blog ) {
-                if ( WP_TESTS_SUBDOMAIN_INSTALL ) {
-                        $newdomain = $blog.'.'.preg_replace( '|^www\.|', '', WP_TESTS_DOMAIN );
-                        $path = $base;
-                } else {
-                        $newdomain = WP_TESTS_DOMAIN;
-                        $path = $base.$blog.'/';
-                }
-                wpmu_create_blog( $newdomain, $path, $blog, email_exists(WP_TESTS_EMAIL) , array( 'public' =&gt; 1 ), 1 );
-
-        }
-}
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbootstrapphp"></a>
<div class="modfile"><h4>Modified: trunk/bootstrap.php (838 => 839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bootstrap.php        2012-07-01 21:42:52 UTC (rev 838)
+++ trunk/bootstrap.php        2012-07-01 22:10:46 UTC (rev 839)
</span><span class="lines">@@ -30,6 +30,16 @@
</span><span class="cx"> 
</span><span class="cx"> system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/bin/install.php' ) . ' ' . escapeshellarg( $config_file_path ) );
</span><span class="cx"> 
</span><ins>+if ( defined( 'WP_TESTS_MULTISITE' ) &amp;&amp; WP_TESTS_MULTISITE ) {
+        define( 'MULTISITE', true );
+        define( 'SUBDOMAIN_INSTALL', false );
+        define( 'DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN );
+        define( 'PATH_CURRENT_SITE', '/' );
+        define( 'SITE_ID_CURRENT_SITE', 1 );
+        define( 'BLOG_ID_CURRENT_SITE', 1 );
+        $GLOBALS['base'] = '/';
+}
+
</ins><span class="cx"> require dirname( __FILE__ ) . '/wp-testlib/functions.php';
</span><span class="cx"> 
</span><span class="cx"> // Preset WordPress options defined in bootstrap file.
</span></span></pre></div>
<a id="trunkwptestlibfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-testlib/functions.php (838 => 839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testlib/functions.php        2012-07-01 21:42:52 UTC (rev 838)
+++ trunk/wp-testlib/functions.php        2012-07-01 22:10:46 UTC (rev 839)
</span><span class="lines">@@ -1,31 +1,5 @@
</span><span class="cx"> &lt;?php
</span><del>-/**
- * Generate a hash to be used when comparing installed version against
- * codebase and current configuration
- * @return string $hash sha1 hash
- **/
-function test_version_check_hash() {
-        $hash = '';
-        $db_version = get_option( 'db_version' );
-        if ( defined('WP_ALLOW_MULTISITE') &amp;&amp; WP_ALLOW_MULTISITE ) {
-                $version = $db_version;
-                if( defined( 'WP_TESTS_BLOGS' ) ) {
-                        $version .= WP_TESTS_BLOGS;
-                }
-                if( defined( 'WP_TESTS_SUBDOMAIN_INSTALL' ) ) {
-                        $version .= WP_TESTS_SUBDOMAIN_INSTALL;
-                }
-                if( defined( 'WP_TESTS_DOMAIN' ) ) {
-                        $version .= WP_TESTS_DOMAIN;
-                }
</del><span class="cx"> 
</span><del>-        } else {
-                $version = $db_version;
-        }
-
-        return sha1($version);
-}
-
</del><span class="cx"> // For adding hooks before loading WP
</span><span class="cx"> function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
</span><span class="cx">         global $wp_filter, $merged_filters;
</span></span></pre>
</div>
</div>

</body>
</html>