WordPress.org

Make WordPress Core

Ticket #23066: second_try.diff

File second_try.diff, 2.8 KB (added by chriscct7, 5 years ago)

Second Try Diff

  • bin/install.php

    diff --git a/bin/install.php b/bin/install.php
    index c3aa298..dd4fe5b 100644
    a b  
    77error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
    88
    99$config_file_path = $argv[1];
    10 
    11 $config_dir = dirname( $config_file_path );
     10$multisite = ! empty( $argv[2] );;
    1211
    1312define( 'WP_INSTALLING', true );
    1413require_once $config_file_path;
    15 require_once $config_dir . '/lib/functions.php';
     14require_once dirname( $config_file_path ) . '/lib/functions.php';
    1615
    1716$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
    1817$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
    require_once ABSPATH . '/wp-includes/wp-db.php'; 
    2625define( 'WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version' );
    2726
    2827$wpdb->suppress_errors();
    29 $wpdb->hide_errors();
    3028$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 );
    3132
    3233if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) && file_get_contents( WP_TESTS_VERSION_FILE ) == $hash )
    3334        return;
    3435
    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' );
    3837$wpdb->select( DB_NAME, $wpdb->dbh );
    3938
    40 echo "Installing" . PHP_EOL;
     39echo "Installing..." . PHP_EOL;
    4140
    4241foreach ( $wpdb->tables() as $table => $prefixed_table ) {
    4342        $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
    foreach ( $wpdb->tables() as $table => $prefixed_table ) { 
    4645foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
    4746        $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
    4847
    49         if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) {
     48        // We need to create references to ms global tables.
     49        if ( $multisite )
    5050                $wpdb->$table = $prefixed_table;
    5151}
    5252
    53 if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) {
     53wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
     54
     55if ( $multisite ) {
    5456        echo "Installing network..." . PHP_EOL;
    5557
    5658        define( 'WP_INSTALLING_NETWORK', true );
    5759
    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;
    6062
    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 );
    6265}
    6366
    64 file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() );
    65  No newline at end of file
     67file_put_contents( WP_TESTS_VERSION_FILE, $hash );
     68 No newline at end of file