diff --git a/bin/install.php b/bin/install.php
index c3aa298..dd4fe5b 100644
a
|
b
|
|
7 | 7 | error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT ); |
8 | 8 | |
9 | 9 | $config_file_path = $argv[1]; |
10 | | |
11 | | $config_dir = dirname( $config_file_path ); |
| 10 | $multisite = ! empty( $argv[2] );; |
12 | 11 | |
13 | 12 | define( 'WP_INSTALLING', true ); |
14 | 13 | require_once $config_file_path; |
15 | | require_once $config_dir . '/lib/functions.php'; |
| 14 | require_once dirname( $config_file_path ) . '/lib/functions.php'; |
16 | 15 | |
17 | 16 | $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; |
18 | 17 | $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; |
… |
… |
require_once ABSPATH . '/wp-includes/wp-db.php'; |
26 | 25 | define( 'WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version' ); |
27 | 26 | |
28 | 27 | $wpdb->suppress_errors(); |
29 | | $wpdb->hide_errors(); |
30 | 28 | $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); |
| 29 | $wpdb->suppress_errors( false ); |
| 30 | |
| 31 | $hash = get_option( 'db_version' ) . ' ' . (int) $multisite . ' ' . sha1_file( $config_file_path ); |
31 | 32 | |
32 | 33 | if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) && file_get_contents( WP_TESTS_VERSION_FILE ) == $hash ) |
33 | 34 | return; |
34 | 35 | |
35 | | $wpdb->query( 'SET storage_engine = INNODB;' ); |
36 | | $wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" ); |
37 | | $wpdb->query( 'CREATE DATABASE '.DB_NAME.";" ); |
| 36 | $wpdb->query( 'SET storage_engine = INNODB' ); |
38 | 37 | $wpdb->select( DB_NAME, $wpdb->dbh ); |
39 | 38 | |
40 | | echo "Installing…" . PHP_EOL; |
| 39 | echo "Installing..." . PHP_EOL; |
41 | 40 | |
42 | 41 | foreach ( $wpdb->tables() as $table => $prefixed_table ) { |
43 | 42 | $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); |
… |
… |
foreach ( $wpdb->tables() as $table => $prefixed_table ) { |
46 | 45 | foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { |
47 | 46 | $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); |
48 | 47 | |
49 | | if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { |
| 48 | // We need to create references to ms global tables. |
| 49 | if ( $multisite ) |
50 | 50 | $wpdb->$table = $prefixed_table; |
51 | 51 | } |
52 | 52 | |
53 | | if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { |
| 53 | wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); |
| 54 | |
| 55 | if ( $multisite ) { |
54 | 56 | echo "Installing network..." . PHP_EOL; |
55 | 57 | |
56 | 58 | define( 'WP_INSTALLING_NETWORK', true ); |
57 | 59 | |
58 | | install_network(); |
59 | | populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL ); |
| 60 | $title = WP_TESTS_TITLE . ' Network'; |
| 61 | $subdomain_install = false; |
60 | 62 | |
61 | | //system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) ); |
| 63 | install_network(); |
| 64 | populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install ); |
62 | 65 | } |
63 | 66 | |
64 | | file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() ); |
65 | | No newline at end of file |
| 67 | file_put_contents( WP_TESTS_VERSION_FILE, $hash ); |
| 68 | No newline at end of file |