profile-command
profile-command copied to clipboard
Permit running requests as frontend vs. backend
We should only load the request as backend when the user explicitly designates such:
wp profile stage --url=domain.com/wp-admin/
A question about this one: is somehow possible atm to execute a profiling against /wp-admin/* urls?
@pioneerskies I just tried, as I thought it would be a simple matter of adding an authorized --user=<user> to the request, but It seems to always fail because of a redirect. I'll have to investigate this in more detail, but at first glance, the profiling seems to work on the frontend only right now.
Thanks @schlessera for the kind reply; this confirms my evidence :)
Are they any news related to? Is it now possible to profile /wp-admin too?
The problem lays in load_wordpress_with_template method of profiler class ( called by run() ), which loads template-loader.php, and so triggering wp_redirect_admin_locations() attached to template_redirect filter.
This could also be a step towards profiling ajax request #4
Any way to work around this? I really need to profile an admin page. Are there other ways to profile these in a simple way that doesnt involve xdebug or similar?
So, I realize this is several years old, but HUGE thanks to @Kilbourne who provided the clues needed to solve this. I simply removed that hook and we're golden! I hope this helps out anyone else.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
add_action('init', function() {
remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
});
}