profile-command icon indicating copy to clipboard operation
profile-command copied to clipboard

Permit running requests as frontend vs. backend

Open danielbachhuber opened this issue 9 years ago • 7 comments

We should only load the request as backend when the user explicitly designates such:

wp profile stage --url=domain.com/wp-admin/

danielbachhuber avatar Aug 25 '16 22:08 danielbachhuber

A question about this one: is somehow possible atm to execute a profiling against /wp-admin/* urls?

alessandro-fazzi avatar Sep 06 '17 10:09 alessandro-fazzi

@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.

schlessera avatar Sep 08 '17 08:09 schlessera

Thanks @schlessera for the kind reply; this confirms my evidence :)

alessandro-fazzi avatar Sep 08 '17 15:09 alessandro-fazzi

Are they any news related to? Is it now possible to profile /wp-admin too?

mrdonthave avatar Sep 19 '18 12:09 mrdonthave

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

Kilbourne avatar Oct 17 '18 12:10 Kilbourne

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?

torarnv avatar Nov 06 '18 22:11 torarnv

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);
	});
}

nhadsall avatar Sep 10 '21 02:09 nhadsall