[wp-trac] [WordPress Trac] #26111: K (was: wp_localize_script array from callback for performance)
WordPress Trac
noreply at wordpress.org
Sun Apr 12 16:40:20 UTC 2015
#26111: K
------------------------------------+-----------------------------
Reporter: ciantic | Owner: wonderboymusic
Type: enhancement | Status: reopened
Priority: high | Milestone: 4.2
Component: Script Loader | Version: 2.6
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses: performance
------------------------------------+-----------------------------
Changes (by DrewAPicture):
* keywords: has-patch 2nd-opinion => has-patch dev-feedback
* priority: low => high
Comment:
Replying to [comment:15 jdgrimes]:
> Unfortunately, this causes issues when someone is localizing a script
with a string that just happens to also be a function name.
Looking more closely at `WP_Scripts::localize()`, I think we kind of
painted ourselves into a corner by not properly type-checking `$l10n` as
an array before [31030], instead just casting whatever is passed as an
array. Meaning of course, that anybody previously passing a string would
have been within bounds.
> I'm not sure if this will be a common problem, but it could really break
things, even kill a site (we're just lucky that die isn't being called in
the middle of every page load in this case).
@wonderboymusic might have a better idea, but the best I can come up with
would be a fourth parameter to toggle whether the third parameter should
be considered callable. Not exactly elegant but would account for back-
compat.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26111#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list