[wp-trac] [WordPress Trac] #38054: class.wp-scripts.php - add_action when init is already doing
WordPress Trac
noreply at wordpress.org
Wed Sep 14 13:28:03 UTC 2016
#38054: class.wp-scripts.php - add_action when init is already doing
---------------------------+------------------------------
Reporter: stodorovic | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: 4.6.1
Severity: normal | Resolution:
Keywords: | Focuses:
---------------------------+------------------------------
Description changed by SergeyBiryukov:
Old description:
> 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
New description:
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
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38054#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list