WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

#41728 closed feature request (duplicate)

Give us ability to debug WP Hooks (will be excellent for improvement)

Reported by: tazotodua Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: Cc:

Description

I have seen some plugins that debug WP Hooks execution times (Query Monitor, Debug bar- slow actions), however, none of them does the following..

I wanted that WP had a hook (for each added function), that should be fired before and after any HOOK-ed function. for example, XYZ theme/plugin adds its typical function with add_action or add_filter.

Then we should have ability to create a function, that will be attached to all individual functions (which are hooked in "ANY" action or filter):

my_function_before_exec($function_name=false){
    $GLOBALS['my_exec_times'][$function_name]['start']= microtime();
}

my_function_after_exec($function_name=false){
    $GLOBALS['my_exec_times'][$function_name]['end']= microtime();
}

so, WP should have something like that, within it's core, that could support/had filter, to be attached to any individual hook-ed function.

that will be excellent to create a profiler plugin, that could find out the exectuion times for all functions, and we could easily detect heavy plugins/codes. That will be good for WP optimization.

Change History (3)

#1 @SergeyBiryukov
5 months ago

  • Component changed from General to Plugins

#2 @ocean90
5 months ago

Is this different from the proposal in #38183?

#3 @johnbillion
5 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

It is technically possible to perform this sort of logging already, but it's very hacky. The wp profile command provides this, and an upcoming version of Query Monitor will provide this too. That said, it would be much easier (and much less fragile) if it was a supported feature in core.

Closing as a duplicate of #38183

Note: See TracTickets for help on using tickets.