[wp-trac] [WordPress Trac] #57427: WP_Locale doesn't initialize property arrays before using them

WordPress Trac noreply at wordpress.org
Fri Jan 6 22:19:51 UTC 2023


#57427: WP_Locale doesn't initialize property arrays before using them
--------------------------+---------------------
 Reporter:  tyxla         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.2
Component:  I18N          |     Version:  6.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by azaozz):

 Replying to [comment:5 tyxla]:

 > Yes, it appears so!

 Don't think that's possible? :)

 As @SergeyBiryukov mentioned `WP_Locale` is initialized (in wp-
 settings.php) relatively early. `$scripts->add_inline_script()` becomes
 available later, after the WP_Dependencies API is initialized and is
 expected to be used after the `init` action (or throws "Doing it wrong!").

 Imho it seems that "something" is trying to load/initialize the
 WP_Dependencies API without loading WP. This is a big "Doing it wrong!"
 and seems unrelated to the code in Gutenberg.

 > Would removing this warning make it harder to determine why the locale
 data is not loaded?

 Yes, seems it will "obfuscate" it.

 On the other hand I'm +1 for the patch/PR as marking something as array in
 the docblock but then setting it to `null` is a pretty bad practice. Why
 use the wrong type? There should be another way to indicate improper
 usage.

 > `WP_Locale`, as a module, should be abstracted in a way that allows it
 to work as a module, regardless of where it's dropped.

 Hmmm, but it is not a module? It depends on other parts of WP, is not
 designed to be self-contained, it is impossible to be used "stand alone",
 and there is no reason to use it as such.

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


More information about the wp-trac mailing list