[wp-trac] [WordPress Trac] #32541: Call to a member function do_items on a non-object ($wp_styles)

WordPress Trac noreply at wordpress.org
Sat Jun 6 18:23:13 UTC 2015

#32541: Call to a member function do_items on a non-object ($wp_styles)
 Reporter:  Frozzare       |       Owner:
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  4.3
Component:  Script Loader  |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:

Comment (by DrProtocols):

 With reference to the patch attached to this ticket - it does not properly
 fix the issue because it simply adds the condition to return the empty
 array if the global $wp_styles is not set to an instantiation of WP_Styles
 - this introduces yet another assumption that it is OK under _any_
 circumstance for $wp_styles to not be set. This is _not_ OK because there
 is no requirement that the caller of wp_print_styles() should have already
 ensured that the global $wp_styles is validly set.

 Whilst I am happy for the ticket I raised to be closed as a duplicate
 based on it reporting the same fatal error we should be clear that the
 ticket I raised reported what was in fact a change to code logic and
 behaviour with no justification and without taking into account the
 context of the statement that was changed. It should not be required for a
 caller of wp_print_styles() to have to determine whether or not the global
 $wp_styles is properly set or not - but with the change in
 wp_print_styles() that has been made it then becomes a requirement for
 every caller of wp_print_styles() to have to explicitly call wp_styles()
 before calling wp_print_styles(). I really do not believe that this was
 the intention of the change that was made to wp_print_styles() - if it is
 really necessary to have the final statement of wp_print_styles() be
         return $wp_styles->do_items( $handles );
 then the call to wp_styles() to ensure that $wp_styles is set must be
 included in the earlier conditional statement to maintain the current
 functional usage of wp_print_styles(). Otherwise the change to that final
 statement should be reverted so that it calls wp_styles().


Ticket URL: <https://core.trac.wordpress.org/ticket/32541#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list