PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
← All changes | includes/public/class-charitable-session.php +11 -0 1.8.11.3 → 1.8.13 View file →
@@ -280,8 +280,19 @@
280 280 */
281 281 public function add_donation( $campaign_id, $amount, $period = 'once' ) {
282 282 $donations = $this->get( 'donations' );
283 283
284 + /*
285 + * get() returns false when the key is not in the session, which is the normal state for the
286 + * first donation of a fresh session. Assigning $donations[ $campaign_id ] to that false
287 + * relied on PHP silently converting it to an array - deprecated in PHP 8.1 and a fatal
288 + * TypeError in PHP 9, on the donation path. add_donation_key() below already guards exactly
289 + * this way; this method was simply missing it.
290 + */
291 + if ( ! is_array( $donations ) ) {
292 + $donations = array();
293 + }
294 +
284 295 $campaign_donation = isset( $donations[ $campaign_id ] ) ? $donations[ $campaign_id ] : array();
285 296 $campaign_donation['amount'] = floatval( charitable_get_currency_helper()->cast_to_decimal_format( $amount ) );
286 297 $campaign_donation['donation_period'] = $period;
287 298