Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

675
Views
PHP Deprecated: Automatic conversion of false to array is deprecated adodb-mssqlnative.inc.php on line 154

We are upgrading PHP to version 8.1. Using MS Sql Server DB. It all seems to work correctly but I see repeated messages in the log file:

[03-Feb-2022 11:51:18 America/New_York] PHP Deprecated: Automatic conversion of false to array is deprecated in C:...\includes\adodb\drivers\adodb-mssqlnative.inc.php on line 154

I've updated adodb to version version 5.22 but that did not stop the messges from logging. The ini file has

extension=php_sqlsrv_81_nts_x64.dll
extension=php_pdo_sqlsrv_81_nts_x64.dll

Does anyone know how to fix this problem?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is a backwards incompatibility in the library itself. PHP 8.1 no longer allows autovivification of false-y values

PHP natively allows for autovivification (auto-creation of arrays from falsey values). This feature is very useful and used in a lot of PHP projects, especially if the variable is undefined. However, there is a little oddity that allows creating an array from a false and null value.

And they give this example

// From false
$arr = false;
$arr[] = 2;

I went and found the file in question and this is the function it's in

function ServerInfo() {
    global $ADODB_FETCH_MODE;
    static $arr = false;
    if (is_array($arr))
        return $arr;
    if ($this->fetchMode === false) {
        $savem = $ADODB_FETCH_MODE;
        $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    } elseif ($this->fetchMode >=0 && $this->fetchMode <=2) {
        $savem = $this->fetchMode;
    } else
        $savem = $this->SetFetchMode(ADODB_FETCH_NUM);

    $arrServerInfo = sqlsrv_server_info($this->_connectionID);
    $ADODB_FETCH_MODE = $savem;
    $arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
    $arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
    return $arr;
}

The problem is that it starts with

static $arr = false;

and then tries to autovivificate a non-array (line 154 in your error)

$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];

You should be able to fix it (in theory) by making sure it's an array (something they should have done anyways). Add this above that line to make it one before it tries to append

if(!is_array($arr)) $arr = [];
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!