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
I encountered a fatal error when using the [give_totals] shortcode due to the improper use of implode() within the give_totals.php file. The error occurs when implode() is called on a variable that is not consistently an array, which causes issues in PHP 8 and above.
Error Message:
Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type array, string given...
File and Line: give_totals.php within the Give Totals widget.
Solution: To resolve this issue, please ensure that the variable being passed to implode() is an array. Here’s a suggested fix to check if the variable is an array before using implode:
// Check if 'ids' is an array before applying implode if (is_array($attributes['ids'])) { $ids = implode(',', $attributes['ids']); } else { $ids = $attributes['ids']; }
Alternatively, this can be handled with a simple fallback in case ids is a string:
It's worth mentioning that this error does not occur in PHP 7.4 because it does not enforce strict typing in the same way as PHP 8+. Downgrading to PHP 7.4 can temporarily bypass the issue; however, PHP 7.4 reached its end of active support
Please let me know if further details are needed, and thank you for your attention to this issue!
The text was updated successfully, but these errors were encountered:
I encountered a fatal error when using the [give_totals] shortcode due to the improper use of implode() within the give_totals.php file. The error occurs when implode() is called on a variable that is not consistently an array, which causes issues in PHP 8 and above.
Error Message:
Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type array, string given...
File and Line: give_totals.php within the Give Totals widget.
Solution: To resolve this issue, please ensure that the variable being passed to implode() is an array. Here’s a suggested fix to check if the variable is an array before using implode:
// Check if 'ids' is an array before applying implode if (is_array($attributes['ids'])) { $ids = implode(',', $attributes['ids']); } else { $ids = $attributes['ids']; }
Alternatively, this can be handled with a simple fallback in case ids is a string:
$ids = is_array($attributes['ids']) ? implode(',', $attributes['ids']) : $attributes['ids'];
This fix should prevent compatibility issues with PHP 8+.
Environment:
PHP Version: 8.3
GiveWP Version: 2.0.1
WordPress Version: 6.6.2
PHP Version Note:
It's worth mentioning that this error does not occur in PHP 7.4 because it does not enforce strict typing in the same way as PHP 8+. Downgrading to PHP 7.4 can temporarily bypass the issue; however, PHP 7.4 reached its end of active support
Please let me know if further details are needed, and thank you for your attention to this issue!
The text was updated successfully, but these errors were encountered: