• Hi! I’m reviewing all my plugins before our big upgrade from PHP 7.3 to PHP 8.3 and the Donorbox plugin has a small error that causes notices in the logs.

    Here’s the warning:

    PHP Warning:  Trying to access array offset on false in /Users/jer/Sites/dev.gv/wp-content/plugins/donorbox-donation-form/donorbox_embed_campaign.php on line 128 

    It’s from this line of code in donorbox_embed_campaign.php:128 generate_donorbox_iframe_src():

    $options = get_option('donorbox_embed_campaign_options');
    $donorbox_campaign_input = $options['donorbox_embed_campaign_id']; // get the campaign id

    The cause is obvious: The code accesses the $options assuming that it’s an array, but in this case, it’s false, because I never set up the option (I just use the shortcode with the URL in it).

    The fix is simple and harmless, just check that the array element exists before using it:

    $options = get_option('donorbox_embed_campaign_options');
    $donorbox_campaign_input = '';
    if (!empty($options['donorbox_embed_campaign_id'])) {
    $donorbox_campaign_input = $options['donorbox_embed_campaign_id']; // get the campaign id
    }

    Thank you in advance for patching this in the next version 🙏🏻

    BTW if you have a Github please let me know, I couldn’t find a repository in your account for this WP plugin.

    • This topic was modified 1 year, 3 months ago by Jer Clarke.
Viewing 1 replies (of 1 total)
  • Thread Starter Jer Clarke

    (@jerclarke)

    Bumping so hopefully this doesn’t get closed and force me to write it again. This code has been working fine on my site after the transition.

Viewing 1 replies (of 1 total)

The topic ‘PHP8 Error log warning: “Trying to access array offset on false”’ is closed to new replies.