[wp-trac] [WordPress Trac] #63427: User roles property should always be an array, but they sometimes become an object in localized data

WordPress Trac noreply at wordpress.org
Sun Jun 15 08:33:32 UTC 2025


#63427: User roles property should always be an array, but they sometimes become an
object in localized data
-------------------------------------------------+-------------------------
 Reporter:  haruncpi                             |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  6.9
Component:  Users                                |     Version:  2.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-test-info has-unit-    |     Focuses:
  tests 2nd-opinion                              |
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:
     has-patch has-test-info has-unit-tests changes-requested reporter-
     feedback
     => has-patch has-test-info has-unit-tests 2nd-opinion


Comment:

 Still I have the question:

 @haruncpi why you don't simply preprocess the resulting json into an
 array, before delivering it to `wp_localize_script`?

 This not sequential order has been for ages, and I'm not sure if it's a
 bug or just something expected. After checking the history of this
 function, this has been there for easily 15+ years (since WP 1.6 when they
 introduced `array_keys`). Not saying that everything old is correct, but
 I'm still trying to find an useful reason.

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


More information about the wp-trac mailing list