Open dartiss opened 4 years ago
FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "'EUR'" in /wp-content/plugins/artiss-currency-converter/includes/convert-currency.php on line 114
PHP message: PHP Warning: Undefined array key "'PLN'" in /wp-content/plugins/artiss-currency-converter/includes/convert-currency.php on line 115
PHP message: PHP Fatal error: Uncaught DivisionByZeroError: Division by zero in /wp-content/plugins/artiss-currency-converter/includes/convert-currency.php:137
Stack trace:
0 /wp-content/plugins/artiss-currency-converter/includes/convert-currency.php(46): occ_perform_conversion()
1 l/wp-content/plugins/artiss-currency-converter/includes/shortcodes.php(32): occ_convert_currency()
2 /wp-includes/shortcodes.php(355): occ_convert_shortcode()
3 [internal function]: do_shortcode_tag()
4 /wp-includes/shortcodes.php(227): preg_replace_callback()
5 /wp-includes/class-wp-hook.php(308): do_shortcode()
6 /wp-includes/plugin.php(205): WP_Hook->apply_filters()
Errors occur when I try to insert a shortcode into an elementor.
Errors occur when I try to insert a shortcode into an elementor.
What do you mean by "into an elementor"? Can you give me an example of a shortcode that's causing this?
Elementor page builder plugin. An error occurs on PHP 8.1 on 7.4 There are no errors, but out of two shortcodes it practices only one. [convert number=29.99 from="EUR" to="PLN"] [convert number=17 from="EUR" to="PLN"]
On PHP 7.4
PHP Warning: Division by zero in wp-content/plugins/artiss-currency-converter/includes/convert-currency.php on line 137" while reading response header from upstream
Thanks for confirming that.
The plugin shortcodes are only designed to be used within the standard editor, so this is outside of the intended use. However, I do plan to look at this at some point to see if there's an easy fix.
Can you successfully use other shortcodes within those fields?
Can you successfully use other shortcodes within those fields?
I tested the shortcode [current_date format = ‘d/m/Y’] in the problem field - it works fine. I think there is a problem in the plugin currency converter when converting the string in the number and an error occurs when division by zero.
I solved the problem in the field Price add array the output with an analogy in the field Content:
<?php echo esc_html($table_value['table_price']); ?>
replace with
<?php
$table_prices = preg_split('/\r\n|[\r\n]/', $table_value['table_price']);
if (is_array($table_prices) && !empty($table_prices)) :
foreach ($table_prices as $tab_price) :
echo ($tab_price);
endforeach;
endif;
?>
in price-table widget Elementor
So, you've changed the plugin code, but put that PHP in the field? Is that right?
I change PHP code in inc/shortcode/style/price-table/style1.php
theme folder price-table widget for Elementor, and use this shortcode in the field:
[convert number=29.99 from="EUR" to="PLN"]
[convert number=17 from="EUR" to="PLN"]
Thats work fine on PHP 7.4-8.1
I have deployed update #51 which doesn't prevent this from failing but captures the failure, so you don't then see a cascade of further errors.
Not a bug in the code, but if the code is called by anything third party then this can occur.
See https://wordpress.org/support/topic/division-by-zero-error-19/ for discussion.