PHP8.1 compatibility: Automatic conversion of false to array is deprecated in MultichoiceQuestion->getDefaultAltSettings()

Created on 11 August 2023, over 1 year ago

Problem/Motivation

While creating new multichoice question by user with no quiz_multichoice_user_settings I've faced this error:
Deprecated function: Automatic conversion of false to array is deprecated in MultichoiceQuestion->getDefaultAltSettings() (line 707
The reason is that in the 'elseif' branch $settings are set as FALSE by getUserSettings() and then in the 'else' branch attempt to convert it to array leads to warning in PHP8.1.

Proposed resolution

I suggest to return NULL instead of FALSE in case of query gives no result or fail.

๐Ÿ› Bug report
Status

Active

Version

5.0

Component

Code - Multichoice

Created by

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024