Warning: Creating default object from empty value in flexslider_optionset_load() (line 281 of E:\Websites\....\sites\all\modules\contrib\flexslider\flexslider.module).

Created on 27 December 2022, almost 2 years ago
Updated 8 August 2023, over 1 year ago

Problem/Motivation

Warning: Creating default object from empty value in flexslider_optionset_load() (line 281 of E:\....\sites\all\modules\contrib\flexslider\flexslider.module).

Steps to reproduce

Not sure, currently running PHP 7.4.30, error appears in logs but is non-fatal. Now required to move to PHP 8.x which causes this error to be come fatal for the website.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Component

Code

Created by

🇺🇸United States RBlackman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States sgroundwater

    I hit the same error w/ PHP 8.x. I let AI help me with a possible fix. In case it helps others.

    ---
    The error message indicates that the property "options" is being modified on a null value in the function flexslider_optionset_load().

    To fix this issue, you can add a null check before attempting to modify the "options" property. Here's an updated version of the code that includes the null check:

    /**
     * Fetches the given option set and returns it as an object or NULL if no set could be found.
     */
    function flexslider_optionset_load($optionset_name) {
      ctools_include('export');
      $optionset = ctools_export_crud_load('flexslider_optionset', $optionset_name);
      
      if ($optionset !== null) {
        // Ensure the optionset is typecast after being loaded from DB
        _flexslider_typecast_optionset($optionset->options);
      }
      
      return $optionset;
    }

    In the updated code, we added an if statement to check if $optionset is not null before attempting to modify the "options" property. If $optionset is null, the modification will not be executed.

    By including this null check, you can prevent the "Attempt to modify property on null" error.

  • 🇮🇳India dineshkumarbollu

    Provided the patch changes suggested in #3, please review

Production build 0.71.5 2024