Commit 49b38e9
Users: Initialize the
Previously, if any roles were filtered out via `array_filter()` when assigning the `WP_User::$roles` property in `WP_User::get_role_caps()`, the resulting array could contain non-sequential numeric keys, which would then cause it to be treated as an object when JSON-encoded, e.g. in `wp_localize_script()`, instead of a proper array, breaking client-side expectations.
This commit ensures that the `WP_User::$roles` property is always treated as an array.
Follow-up to [2703], [2793], [22118].
Props haruncpi, peterwilsoncc, SirLouen, getsyash, wildworks, johnjamesjacoby, SergeyBiryukov.
Fixes #63427.
git-svn-id: https://develop.svn.wordpress.org/trunk@61210 602fd350-edb4-49c9-b593-d223f7449a82WP_User::$roles property as a sequential array.1 parent 6d36bb7 commit 49b38e9
File tree
2 files changed
+39
-2
lines changed- src/wp-includes
- tests/phpunit/tests
2 files changed
+39
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
| 518 | + | |
519 | 519 | | |
520 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
521 | 527 | | |
522 | 528 | | |
523 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2157 | 2157 | | |
2158 | 2158 | | |
2159 | 2159 | | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
2160 | 2191 | | |
2161 | 2192 | | |
2162 | 2193 | | |
| |||
0 commit comments