You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In includes/formatting.php the give_maybe_sanitize_amount function can sometimes crash when calling number_format(). When this happened to me I was using the IDR currency, which uses the symbol Rp. The symbol is supposed to be removed by this line of code:
// Remove currency symbols from number if any.$number = trim(str_replace(give_currency_symbols(true), '', $number));
But in my case the removal was incomplete. $number was originally "Rp10000", and became "p10000" after the removal. This was because there is another currency, ZAR, that has the symbol R. So depending on the array order from give_currency_sybmols(), the "R" can be removed first before IDR currency is proc'd.
This results in my $number == 'p10000'. And the letter 'p' crashes number_format().
Fatal error: Uncaught Error: number_format(): Argument #1 ($num) must be of type float, string given
in /wp/wp-content/plugins/give/includes/formatting.php on line 269
Details
In includes/formatting.php the
give_maybe_sanitize_amount
function can sometimes crash when callingnumber_format()
. When this happened to me I was using the IDR currency, which uses the symbolRp
. The symbol is supposed to be removed by this line of code:But in my case the removal was incomplete. $number was originally "Rp10000", and became "p10000" after the removal. This was because there is another currency, ZAR, that has the symbol
R
. So depending on the array order fromgive_currency_sybmols()
, the "R" can be removed first before IDR currency is proc'd.This results in my $number == 'p10000'. And the letter 'p' crashes
number_format()
.Call stack:
number_format()
wp-content/plugins/give/includes/formatting.php:269
give_maybe_sanitize_amount()
wp-content/plugins/give/includes/forms/template.php:1935
give_checkout_final_total()
wp-includes/class-wp-hook.php:326
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:348
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-content/plugins/give/includes/forms/template.php:2002
give_checkout_submit()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:348
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-content/plugins/give/includes/forms/template.php:314
give_show_purchase_form()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:348
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-content/plugins/give/includes/gateways/actions.php:64
give_load_ajax_gateway()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:348
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-admin/admin-ajax.php:192
Steps to Reproduce
This was how I discovered the issue. Your own mileage may vary.
The text was updated successfully, but these errors were encountered: