[wp-trac] [WordPress Trac] #25280: wp_localize_script unexpectedly converts numbers to strings
WordPress Trac
noreply at wordpress.org
Thu Sep 24 08:33:19 UTC 2015
#25280: wp_localize_script unexpectedly converts numbers to strings
------------------------------------+-----------------------------
Reporter: adamsilverstein | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: I18N | Version: 3.2
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses: javascript
------------------------------------+-----------------------------
Changes (by Fab1en):
* keywords: has-patch dev-feedback 4.1-early => has-patch dev-feedback
Comment:
Replying to [comment:28 jtsternberg]:
> it will break backwards-compatibility
The only way to break thinks here would be the following :
* in PHP, declare an integer at the first level of the array
* in JavaScript, check that the variable has been transformed to a string
(whereas you should normally expect it to be an integer)
If this is really what you are doing (checking that an integer is
transformed into a string), you just have to wrap the integer into a
string in PHP to fix this.
With the proposed patch, only integers are concerned. Strings containing
integers are left untouched. Moreover, JavaScript is casting the string
into an integer when using in a integer context, so breaking something is
not very likely.
Could you provide your script as an example ?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/25280#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list