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

Issue fork variable-3413356

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

arif.zisu created an issue. See original summary.

arif.zisu’s picture

Status: Active » Needs work
arif.zisu’s picture

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

arif.zisu’s picture

Status: Needs work » Needs review
alena_stanul’s picture

@arif.zisu 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

arif.zisu’s picture

@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 ??