#17299 closed defect (bug) (worksforme)
number_format_i18n improper calls
Reported by: | mhitza | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | trivial | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
I would recommend that in the number_format_i18n function instead of
$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_formatdecimal_point?, $wp_locale->number_formatthousands_sep? );
Force a (double) typecast on the first parameter because somewhere the function is called with a string and it just fills the apache error log with warnings.
Attachments (1)
Change History (9)
#2
@
13 years ago
- Milestone changed from Awaiting Review to 3.3
I'm seeing warnings on 5.3: "Warning: number_format() expects parameter 1 to be double, string given in wp-includes/functions.php on line 155".
#5
in reply to:
↑ 4
;
follow-up:
↓ 6
@
13 years ago
Replying to westi:
We should fix where this is called.
I don't see any warnings in core about this (checked on PHP 5.2.14 and 5.3.3). I've briefly reviewed all calls to number_format_i18n()
, and didn't find anything strange. I guess the purpose of this change is to avoid the warning if a wrong parameter is passed by a plugin or a theme.
#6
in reply to:
↑ 5
@
13 years ago
Replying to SergeyBiryukov:
Replying to westi:
We should fix where this is called.
I don't see any warnings in core about this (checked on PHP 5.2.14 and 5.3.3). I've briefly reviewed all calls to
number_format_i18n()
, and didn't find anything strange. I guess the purpose of this change is to avoid the warning if a wrong parameter is passed by a plugin or a theme.
I don't think we should "hide" warning generated by plugin/theme bugs.
If it's called with a string somewhere, perhaps it should be fixed there.
However I don't get warnings on PHP 5.2.14 with WP_DEBUG on, even if I pass a string directly:
echo number_format_i18n('18');
or evenecho number_format_i18n('test');
Since I've already created the patch while testing, I'll leave it here just in case.