From 3400b823567ecd4cdefdf59866bb245a8fc3121b Mon Sep 17 00:00:00 2001 From: Sunny Ratilal Date: Tue, 9 Apr 2013 09:40:43 +0100 Subject: [PATCH] Fix install script --- bin/install.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/bin/install.php b/bin/install.php index c3aa298..1b8a0db 100644 --- a/bin/install.php +++ b/bin/install.php @@ -7,12 +7,11 @@ error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT ); $config_file_path = $argv[1]; - -$config_dir = dirname( $config_file_path ); +$multisite = true; define( 'WP_INSTALLING', true ); require_once $config_file_path; -require_once $config_dir . '/lib/functions.php'; +require_once dirname( $config_file_path ) . '/lib/functions.php'; $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; @@ -26,18 +25,18 @@ define( 'WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version' ); $wpdb->suppress_errors(); -$wpdb->hide_errors(); $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); +$wpdb->suppress_errors( false ); + +$hash = get_option( 'db_version' ) . ' ' . (int) $multisite . ' ' . sha1_file( $config_file_path ); if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) && file_get_contents( WP_TESTS_VERSION_FILE ) == $hash ) return; -$wpdb->query( 'SET storage_engine = INNODB;' ); -$wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" ); -$wpdb->query( 'CREATE DATABASE '.DB_NAME.";" ); +$wpdb->query( 'SET storage_engine = INNODB' ); $wpdb->select( DB_NAME, $wpdb->dbh ); -echo "Installing…" . PHP_EOL; +echo "Installing..." . PHP_EOL; foreach ( $wpdb->tables() as $table => $prefixed_table ) { $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); @@ -46,19 +45,23 @@ foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); - if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { + // We need to create references to ms global tables. + if ( $multisite ) $wpdb->$table = $prefixed_table; } -if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { +wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); + +if ( $multisite ) { echo "Installing network..." . PHP_EOL; define( 'WP_INSTALLING_NETWORK', true ); - install_network(); - populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL ); + $title = WP_TESTS_TITLE . ' Network'; + $subdomain_install = false; - //system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) ); + install_network(); + populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install ); } -file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() ); \ No newline at end of file +file_put_contents( WP_TESTS_VERSION_FILE, $hash ); \ No newline at end of file -- 1.8.1.5