[wp-trac] [WordPress Trac] #19590: number_format_i18n raise a warning when first parameter is 0
WordPress Trac
wp-trac at lists.automattic.com
Sat Dec 17 18:40:49 UTC 2011
#19590: number_format_i18n raise a warning when first parameter is 0
--------------------------+-----------------------------
Reporter: xmarcos | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: 3.3
Severity: minor | Keywords: has-patch
--------------------------+-----------------------------
'''number_format_i18n''' (/wp-includes/functions.php, line 155) will raise
a warning when the first parameter ''$number'' is not a double/float,
which happens when it receives the value 0.
The error only shows up in the dashboard with a locale active (es_ES) in
this case, screenshot attached.
The fix would be to cast the received value to float.
Current function,
{{{
function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;
$formatted = number_format( $number, absint( $decimals ),
$wp_locale->number_format['decimal_point'],
$wp_locale->number_format['thousands_sep'] );
return apply_filters( 'number_format_i18n', $formatted );
}
}}}
Fix,
{{{
function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;
$formatted = number_format( (float) $number, absint( $decimals ),
$wp_locale->number_format['decimal_point'],
$wp_locale->number_format['thousands_sep'] );
return apply_filters( 'number_format_i18n', $formatted );
}
}}}
It's the first bug i report here, so correct me if I'm doing it wrong.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19590>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list