[wp-trac] [WordPress Trac] #32573: Change in wp_print_styles() causes fatal error if $wp_styles is not set
WordPress Trac
noreply at wordpress.org
Sat Jun 6 17:15:48 UTC 2015
#32573: Change in wp_print_styles() causes fatal error if $wp_styles is not set
---------------------------+-----------------------------
Reporter: DrProtocols | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: trunk
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
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:
https://core.trac.wordpress.org/ticket/32444#comment:43
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
127.0.0.1:59179] PHP Fatal error: Call to a member function do_items() on
a non-object in /Users/ambiguous/Sites/wptest.dev/wp-includes/functions
.wp-styles.php 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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32573>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list