During PHPUnit tests, don't autodetect permalink structure during WP installation.

The unit tests expect non-pretty permalinks, so there's no benefit to detecting
the ability to have pretty permalinks. Moreover, the `wp_remote_get()` call can
cause installation to hang when there are DNS issues.

Fixes #31994.

git-svn-id: https://develop.svn.wordpress.org/trunk@32139 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-04-16 23:59:01 +00:00
parent 41b1d73c03
commit bf3773dbfb
2 changed files with 22 additions and 1 deletions

View File

@ -102,4 +102,16 @@ function _wp_die_handler_txt( $message, $title, $args ) {
echo "\t $k : $v\n";
}
}
}
}
/**
* Set a permalink structure.
*
* Hooked as a callback to the 'populate_options' action, we use this function to set a permalink structure during
* `wp_install()`, so that WP doesn't attempt to do a time-consuming remote request.
*
* @since 4.2.0
*/
function _set_default_permalink_structure_for_tests() {
update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
}

View File

@ -44,8 +44,17 @@ foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
$wpdb->$table = $prefixed_table;
}
// Prefill a permalink structure so that WP doesn't try to determine one itself.
add_action( 'populate_options', '_set_default_permalink_structure_for_tests' );
wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
// Delete dummy permalink structure, as prefilled above.
if ( ! is_multisite() ) {
delete_option( 'permalink_structure' );
}
remove_action( 'populate_options', '_set_default_permalink_structure_for_tests' );
if ( $multisite ) {
echo "Installing network..." . PHP_EOL;