WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 6 months ago

#38054 new enhancement

class.wp-scripts.php - add_action when init is already doing

Reported by: stodorovic Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6.1
Component: Script Loader Keywords: reporter-feedback
Focuses: Cc:
PR Number:

Description (last modified by SergeyBiryukov)

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 (2)

#1 @SergeyBiryukov
3 years ago

  • Description modified (diff)

#2 @desrosj
6 months ago

  • Keywords reporter-feedback added

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.

Note: See TracTickets for help on using tickets.