suppress_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->select( DB_NAME, $wpdb->dbh ); echo "Installing..." . PHP_EOL; foreach ( $wpdb->tables() as $table => $prefixed_table ) { $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); } foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); // We need to create references to ms global tables. if ( $multisite ) $wpdb->$table = $prefixed_table; } wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); if ( $multisite ) { echo "Installing network..." . PHP_EOL; define( 'WP_INSTALLING_NETWORK', true ); $title = WP_TESTS_TITLE . ' Network'; $subdomain_install = false; install_network(); populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install ); } file_put_contents( WP_TESTS_VERSION_FILE, $hash );