Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32573 closed defect (bug) (duplicate)

Change in wp_print_styles() causes fatal error if $wp_styles is not set

Reported by: drprotocols's profile DrProtocols Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Script Loader Keywords:
Focuses: Cc:


In 4.3-alpha there is a change in wp_print_styles() such that the final return statement has become:

        return $wp_styles->do_items( $handles );

whereas in 4.2.2 the statement is:

	return wp_styles()->do_items( $handles );

The change appears to be due to this ticket:

which does not seem to take into account the actual context of this statement. The upshot is that there is now an implicit assumption that the global $wp_styles is already set to an instantiation of the WP_Styles object and when this is not the case the function fails with a fatal error:

[Sat Jun 06 14:19:24.795479 2015] [:error] [pid 7955] [client] PHP Fatal error:  Call to a member function do_items() on a non-object in /Users/ambiguous/Sites/ on line 64

It cannot be assumed that the global $wp_styles is already set to an instantiated WP_Styles object and the explicit use of the wp_styles() function was to instantiate a WP_Styles object and assign to the global $wp_styles if that was not already the case.

The wp_print_styles() function has an explicit requirement that the global $wp_styles is a valid instantiation of a WP_Styles object if it is necessary to use the global:

* @global WP_Styles $wp_styles The WP_Styles object for printing styles.

Either the change needs to be reverted to call wp_styles() in the return statement or an update must be made earlier in the function to add an else clause in prior conditional so that $wp_styles global will be valid when required.

Change History (1)

#1 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #32541.

Note: See TracTickets for help on using tickets.