1 | From 3400b823567ecd4cdefdf59866bb245a8fc3121b Mon Sep 17 00:00:00 2001 |
---|
2 | From: Sunny Ratilal <ratilal.sunny@gmail.com> |
---|
3 | Date: Tue, 9 Apr 2013 09:40:43 +0100 |
---|
4 | Subject: [PATCH] Fix install script |
---|
5 | |
---|
6 | --- |
---|
7 | bin/install.php | 31 +++++++++++++++++-------------- |
---|
8 | 1 file changed, 17 insertions(+), 14 deletions(-) |
---|
9 | |
---|
10 | diff --git a/bin/install.php b/bin/install.php |
---|
11 | index c3aa298..1b8a0db 100644 |
---|
12 | --- a/bin/install.php |
---|
13 | +++ b/bin/install.php |
---|
14 | @@ -7,12 +7,11 @@ |
---|
15 | error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT ); |
---|
16 | |
---|
17 | $config_file_path = $argv[1]; |
---|
18 | - |
---|
19 | -$config_dir = dirname( $config_file_path ); |
---|
20 | +$multisite = true; |
---|
21 | |
---|
22 | define( 'WP_INSTALLING', true ); |
---|
23 | require_once $config_file_path; |
---|
24 | -require_once $config_dir . '/lib/functions.php'; |
---|
25 | +require_once dirname( $config_file_path ) . '/lib/functions.php'; |
---|
26 | |
---|
27 | $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; |
---|
28 | $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; |
---|
29 | @@ -26,18 +25,18 @@ |
---|
30 | define( 'WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version' ); |
---|
31 | |
---|
32 | $wpdb->suppress_errors(); |
---|
33 | -$wpdb->hide_errors(); |
---|
34 | $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); |
---|
35 | +$wpdb->suppress_errors( false ); |
---|
36 | + |
---|
37 | +$hash = get_option( 'db_version' ) . ' ' . (int) $multisite . ' ' . sha1_file( $config_file_path ); |
---|
38 | |
---|
39 | if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) && file_get_contents( WP_TESTS_VERSION_FILE ) == $hash ) |
---|
40 | return; |
---|
41 | |
---|
42 | -$wpdb->query( 'SET storage_engine = INNODB;' ); |
---|
43 | -$wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" ); |
---|
44 | -$wpdb->query( 'CREATE DATABASE '.DB_NAME.";" ); |
---|
45 | +$wpdb->query( 'SET storage_engine = INNODB' ); |
---|
46 | $wpdb->select( DB_NAME, $wpdb->dbh ); |
---|
47 | |
---|
48 | -echo "Installing…" . PHP_EOL; |
---|
49 | +echo "Installing..." . PHP_EOL; |
---|
50 | |
---|
51 | foreach ( $wpdb->tables() as $table => $prefixed_table ) { |
---|
52 | $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); |
---|
53 | @@ -46,19 +45,23 @@ |
---|
54 | foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { |
---|
55 | $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); |
---|
56 | |
---|
57 | - if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { |
---|
58 | + // We need to create references to ms global tables. |
---|
59 | + if ( $multisite ) |
---|
60 | $wpdb->$table = $prefixed_table; |
---|
61 | } |
---|
62 | |
---|
63 | -if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { |
---|
64 | +wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); |
---|
65 | + |
---|
66 | +if ( $multisite ) { |
---|
67 | echo "Installing network..." . PHP_EOL; |
---|
68 | |
---|
69 | define( 'WP_INSTALLING_NETWORK', true ); |
---|
70 | |
---|
71 | - install_network(); |
---|
72 | - populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL ); |
---|
73 | + $title = WP_TESTS_TITLE . ' Network'; |
---|
74 | + $subdomain_install = false; |
---|
75 | |
---|
76 | - //system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) ); |
---|
77 | + install_network(); |
---|
78 | + populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install ); |
---|
79 | } |
---|
80 | |
---|
81 | -file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() ); |
---|
82 | \ No newline at end of file |
---|
83 | +file_put_contents( WP_TESTS_VERSION_FILE, $hash ); |
---|
84 | \ No newline at end of file |
---|
85 | -- |
---|
86 | 1.8.1.5 |
---|
87 | |
---|