Opened 10 years ago
Closed 5 months ago
#38054 closed enhancement (invalid)
class.wp-scripts.php - add_action when init is already doing
| Reported by: | stodorovic | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Script Loader | Version: | 4.6.1 |
| Severity: | normal | Keywords: | reporter-feedback |
| Cc: | Focuses: |
Description (last modified by )
Hi,
I've simple WP installation and I'm trying to make "my profiler" which will show executing times of all actions. I just found an issue in class.wp-scripts.php. Plugin Query monitor runs wp_register_script( 'debug-bar', false, array( 'query-monitor') ); inside init action. (it's first call of wp_register_script). Then constructor of WP_Scripts runs add_action( 'init', array( $this, 'init' ), 0 ), but action is already doing and my profiler shows warning about it ($merged_filters['init'] has reset state).
I think that constructor should be:
public function __construct() {
$this->init();
if ( ! did_action( 'init' ) ) add_action( 'init', array( $this, 'init' ), 0 );
}
Sasa
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi @stodorovic,
Welcome to Trac!
I have been unable to reproduce the issue you are describing. Can you detail where your profiler is retrieving that error from? And can you provide a code example to reproduce the issue?
I have tried to reproduce this using the Query Monitor plugin, but have been unable to do so.