Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#25462 closed defect (bug) (fixed)

set_group fails on deregistered but not dequeued

Reported by: tivnet's profile tivnet Owned by: chriscct7's profile chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch commit
Focuses: Cc:



add_action('wp_print_scripts', function () {

results in:

PHP Notice:  Undefined index: autosave in class.wp-scripts.php on line 169
PHP Notice:  Trying to get property of non-object in class.wp-scripts.php on line 169

With wp_dequeue_script('autosave');, everything is fine.

But without dequeue, probably, the attached patch might help.

Attachments (2)

set_group_fails_on_deregistered_but_not_dequeued.patch (605 bytes) - added by tivnet 11 years ago.
25462.patch (605 bytes) - added by chriscct7 9 years ago.

Download all attachments as: .zip

Change History (8)

#1 @tivnet
11 years ago

Any resolution on this? Thank you!

#2 @SergeyBiryukov
10 years ago

Appears to be a duplicate of #20912 (which has the same use case and the same patch).

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#3 @nacin
10 years ago

  • Component changed from Warnings/Notices to Script Loader
  • Keywords 2nd-opinion added

Hm. #20912 was closed.

#4 @tivnet
10 years ago

I checked again, with 3.8 - and there was no warning.
However, theoretically, args can be null

	public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
		if ( isset($this->registered[$handle]) )
			return false;
		$this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
		return true;

So, checking for if ( $this->registered[$handle]->args === 1 ) may produce warnings.
I believe, the code will be safer with the patch.

9 years ago

#5 @chriscct7
9 years ago

  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to chriscct7
  • Status changed from new to accepted

Refreshed patch. Good to go.

#6 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 34862:

Scripts: in WP_Scripts::set_group(), the args prop of the _WP_Dependency instance defaults to null - check that it is set before comparing.

Props tivnet, chriscct7.
Fixes #25462.

Note: See TracTickets for help on using tickets.