• Resolved Orestis Samaras

    (@orestissam)


    Hello

    Recently did a fresh installation of the Nelio AB testing plugin (version 8.2.2), and as soon as the plugin was activated received the following warning:

    Trying to access array offset on value of type null

    The backtrace is the following

    wp-content/plugins/nelio-ab-testing/includes/utils/functions/cookie-testing.php:29
    {closure}()
    wp-content/plugins/nelio-ab-testing/includes/utils/functions/cookie-testing.php:44
    nab_get_variant_loading_strategy()
    wp-content/plugins/nelio-ab-testing/includes/hooks/cookie-testing.php:66
    Nelio_AB_Testing\H\C\disable_incompatible_plugin_settings()
    wp-includes/class-wp-hook.php:341
    do_action('plugins_loaded')
    wp-settings.php:593

    From a very brief look at the code, seems like $setting = $settings->get( 'alternative_loading' ); is returning a null value, thus causing the warning on the next line where $settings['mode'] is accessed.

    Unsure what’s the root cause of that, but a quick patch could be the following:

    $setting  = $settings->get( 'alternative_loading' );
    $mode = isset($setting['mode']) ? $setting['mode'] : 'redirection';

    This ensures that if a value is not set, then the default “redirection” mode will be used.

    Happy to provide more information if needed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Aguilera

    (@davilera)

    Thanks for the heads up. In theory, $mode should be an array and not null, so I’m quite surprised you got this error in the first place. Before applying your fix, I’d like to understand what went wrong (just to make sure it doesn’t end up happening somewhere else). Unfortunately, I can’t reproduce the issue locally… Can you walk me through the steps you took to get there?

    Thread Starter Orestis Samaras

    (@orestissam)

    Hey David,

    Thanks for the quick reply. Honestly didn’t do anything (didn’t even get to accept the terms of use). As soon as the plugin was added I received this error.

    Couple of extra points that might be helpful in debugging this:

    • Plugin was installed using composer (using the wpackagist.org mirror)
    • Plugin was code-activated on a WP VIP hosted website (code-activation ref)
    Plugin Author David Aguilera

    (@davilera)

    Thanks, mate! That was really helpful. I was able to identify and understand what was causing the issue. I’ll work on the fix and publish it in our next release (8.2.3).

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.