PHP 8.1: Automatic conversion of false to array is deprecated

Created on 6 August 2024, 4 months ago

Problem/Motivation

Upon upgrading PHP to 8.1, this warning-level error is output to the screen:

Deprecated function: Automatic conversion of false to array is deprecated in qtip_clean_settings() (line 787 of example.com/sites/all/modules/qtip/qtip.module).

The error is in the function qtip_clean_settings():

On line line 727, $settings['style']['tip'] is set to FALSE.
By line 787, $settings['style']['tip']['corner_position'] is no longer a valid array element, even though the code is trying to unset it. This is due to a change in PHP 8.1 where automatic conversions of FALSE to arrays are deprecated.

Steps to reproduce

1. Turn on error logging and/or display errors
2. Upgrade to PHP 8.1+
3. View any page on the site and the error will appear.

Proposed resolution

To fix this, we can move line 787 up to the isset() check on line 734 as follows:

  // Set the tooltip value properly if it is explicitly set to a position
  if (isset($settings['style']['tip']['corner_position'])) {
    if (!empty($settings['style']['tip']['corner_position'])) {
      $settings['style']['tip']['corner'] = $settings['style']['tip']['corner_position'];
    }
    unset($settings['style']['tip']['corner_position']);
  }
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States hargobind Austin, Texas

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024