mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:38:51 +08:00
Merge pull request #83 from runcommand/22-trailingslash
Trailingslash provided URL to avoid canonical redirect
This commit is contained in:
commit
da150e2cb8
2 changed files with 15 additions and 4 deletions
|
@ -27,3 +27,12 @@ Feature: Basic profile usage
|
||||||
| callback | time |
|
| callback | time |
|
||||||
| total | |
|
| total | |
|
||||||
And STDERR should be empty
|
And STDERR should be empty
|
||||||
|
|
||||||
|
Scenario: Trailingslash provided URL to avoid canonical redirect
|
||||||
|
Given a WP install
|
||||||
|
|
||||||
|
When I run `wp profile hook setup_theme --url=example.com --fields=callback,time`
|
||||||
|
Then STDERR should be empty
|
||||||
|
And STDOUT should be a table containing rows:
|
||||||
|
| callback | time |
|
||||||
|
| total | |
|
||||||
|
|
|
@ -267,11 +267,13 @@ class Command {
|
||||||
* Run the profiler against WordPress
|
* Run the profiler against WordPress
|
||||||
*/
|
*/
|
||||||
private function run_profiler() {
|
private function run_profiler() {
|
||||||
if ( ! isset( WP_CLI::get_runner()->config['url'] ) ) {
|
WP_CLI::add_wp_hook( 'muplugins_loaded', function(){
|
||||||
WP_CLI::add_wp_hook( 'muplugins_loaded', function(){
|
if ( $url = WP_CLI::get_runner()->config['url'] ) {
|
||||||
|
WP_CLI::set_url( trailingslashit( $url ) );
|
||||||
|
} else {
|
||||||
WP_CLI::set_url( home_url( '/' ) );
|
WP_CLI::set_url( home_url( '/' ) );
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
WP_CLI::add_hook( 'after_wp_config_load', function() {
|
WP_CLI::add_hook( 'after_wp_config_load', function() {
|
||||||
if ( defined( 'SAVEQUERIES' ) && ! SAVEQUERIES ) {
|
if ( defined( 'SAVEQUERIES' ) && ! SAVEQUERIES ) {
|
||||||
WP_CLI::error( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" );
|
WP_CLI::error( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue