Deprecated function: Automatic conversion of false to array is deprecated

Created on 9 January 2024, 11 months ago
Updated 7 February 2024, 10 months ago

Getting below Deprecated error while PHP version 8.1 and Drupal 7.99
Deprecated function: Automatic conversion of false to array is deprecated in _variable_options() (line 638 of docroot/sites/all/modules/contrib/variable/variable.module

🐛 Bug report
Status

Needs review

Version

2.5

Component

Code

Created by

🇮🇳India arif.zisu Kolkata

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • Issue created by @arif.zisu
  • 🇮🇳India arif.zisu Kolkata

    diff --git a/docroot/sites/all/modules/contrib/variable/variable.module b/docroot/sites/all/modules/contrib/variable/variable.module
    index 472bba70f..0cd2639f2 100644
    --- a/docroot/sites/all/modules/contrib/variable/variable.module
    +++ b/docroot/sites/all/modules/contrib/variable/variable.module
    @@ -627,6 +627,7 @@ function _variable_language() {
    * - language, Language object
    */
    function _variable_options($options = array()) {
    + $options = [];
    if (!empty($options['language'])) {
    $options['langcode'] = $options['language']->language;
    }

    Fixed it

  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 5.3 & MySQL 5.5
    last update 10 months ago
    PHPLint Failed
  • Status changed to Needs review 10 months ago
  • 🇧🇾Belarus alena_stanul

    I am not agree with patch, because if $options is not empty, then you will artificially reset it to empty array. May be better to use the following code:

    function _variable_options($options = array()) {
      $options = ($options !=FALSE) ? $options : [];
      if (!empty($options['language'])) {...
    

    Thanks

  • 🇮🇳India arif.zisu Kolkata

    @alena_stanul,
    $options value will not work for boolean or empty value right (as it should be always array)??
    So better to set empty array right ?? $options should always array right ??

Production build 0.71.5 2024