Make WordPress Core

Opened 3 months ago

Last modified 2 months ago

#43627 reviewing defect (bug)

Method call uses 2 parameters, but method signature uses 1 parameters

Reported by: kaggdesign Owned by: SergeyBiryukov
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.9.4
Component: Script Loader Keywords: has-patch
Focuses: Cc:


wp-includes/class.wp-dependencies.php, line 106

Method do_item() called with 2 parameters:

				if ( $this->do_item( $handle, $group ) ) {
					$this->done[] = $handle;

Method signature has 1 parameter (same file, line 125)

	public function do_item( $handle ) {
		return isset( $this->registered[ $handle ] );

Even taking into consideration further inheritance, second parameter $group should be added to method signature, to avoid code misunderstanding, and Code Smell warning in PhpStorm.

Attachments (1)

43627.diff (1.5 KB) - added by soulseekah 3 months ago.

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
3 months ago

  • Component changed from General to Script Loader
  • Milestone changed from Awaiting Review to 5.0

Previously: #24770

This is simple class inheritance. The do_item() method in class.wp-dependencies.php is a placeholder meant to be overwritten when extending the class. When handling scripts WP_Dependencies is extended with WP_Scripts. So $this->do_item() executes the do_item() method of WP_Scripts that expects the second argument. (The WP_Dependencies::do_item() is still used in WP_Scripts but note how it's called with parent::do_item($handle).)

#24770 was not about the signature though, but rather about a missing wp_footer() call in a theme.

Let's use this ticket to add $group parameter to WP_Dependencies::do_item() for consistency with WP_Scripts::do_item(), to avoid further confusion.

Last edited 3 months ago by SergeyBiryukov (previous) (diff)

3 months ago

#2 @SergeyBiryukov
3 months ago

  • Keywords has-patch added

#3 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.