Adodb inc php deprecated

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 

I didn’t see the issue mentioned in their list. It’s a temporary fix so we might just go with ~DEPRICATED in the error logging.

1 Answer 1

This is a known issue of backwards incompatibility, affecting the ADOdb library version 5.22.1 and older. PHP 8.1 warns you on autovivification of false-y values and some future version of PHP will throw an error when you do it.

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

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

Читайте также:  Print in java hello world

Источник

Deprecated Functionality

Connect to MySQL database agora, and generate a menu from an SQL statement where the captions are in the 1st column, and the value to send back to the server is in the 2nd column.

include('adodb.inc.php'); # load code common to ADOdb $conn = &adoNewConnection('mysql'); # create a connection $conn->pConnect('localhost','userid','','agora');# connect to MySQL, agora db $sql = 'select CustomerName, CustomerID from customers'; $rs = $conn->execute($sql); print $rs->getMenu('GetCust','Mary Rosli');

Here we define a menu named GetCust, with the menu option ‘Mary Rosli’ selected. See GetMenu(). We also have functions that return the recordset as an array: GetArray(), and as an associative array with the key being the first column: GetAssoc().

Example 9: Exporting in CSV or Tab-Delimited Format

We provide some helper functions to export in comma-separated-value (CSV) and tab-delimited formats:

include_once('/path/to/adodb/toexport.inc.php'); include_once('/path/to/adodb/adodb.inc.php'); $db = &newADOConnection('mysqli'); $db->connect($server, $userid, $password, $database); $rs = $db->execute('select fname as "First Name", surname as "Surname" from table'); print "
"; print rs2csv($rs); # return a string, CSV format print '
'
; $rs->moveFirst(); # note, some databases do not support MoveFirst print rs2tab($rs,false); # return a string, tab-delimited # false == suppress field names in first line print '
'
; $rs->moveFirst(); rs2tabout($rs); # send to stdout directly (there is also an rs2csvout function) print "

"; $rs->moveFirst(); $fp = fopen($path, "w"); if ($fp) { rs2csvfile($rs, $fp); # write to file (there is also an rs2tabfile function) fclose($fp); }

Carriage-returns or newlines are converted to spaces. Field names are returned in the first line of text. Strings containing the delimiter character are quoted with double-quotes. Double-quotes are double-quoted again. This conforms to Excel import and export guide-lines.

All the above functions take as an optional last parameter, $addtitles which defaults to true. When set to false field names in the first line are suppressed.

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated — php 8.1 #781

Deprecated — php 8.1 #781

Comments

thank you for maintaining this project for years.

When updating to PHP 8.1 in my xampp https://www.apachefriends.org/

Environment I get the following notices:

Deprecated: Return type of ADODB_Iterator_empty::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3456

Deprecated: Return type of ADODB_Iterator_empty::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3460

Deprecated: Return type of ADODB_Iterator_empty::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3452

Deprecated: Return type of ADODB_Iterator_empty::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3448

Deprecated: Return type of ADODB_Iterator_empty::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3446

Deprecated: Return type of ADORecordSet_empty::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3512

Deprecated: Return type of ADODB_Iterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3584

Deprecated: Return type of ADODB_Iterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3588

Deprecated: Return type of ADODB_Iterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3580

Deprecated: Return type of ADODB_Iterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3576

Deprecated: Return type of ADODB_Iterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3572

Deprecated: Return type of ADORecordSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ~\adodb\adodb-php\adodb.inc.php on line 3672

The text was updated successfully, but these errors were encountered:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1: adodb-time.inc.php uses deprecated [gm]strftime() #963

PHP 8.1: adodb-time.inc.php uses deprecated [gm]strftime() #963

Comments

Description

strftime() and gmstrftime() have been deprecated. Use date() instead (for locale-independent formatting), or IntlDateFormatter::format() (for locale-dependent formatting).

The affected function calls can be found here:

FILE: ADOdb/adodb-time.inc.php ------------------------------------------------------------------------------------------------------------------------------------------------------ FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 4 LINES ------------------------------------------------------------------------------------------------------------------------------------------------------ 429 | WARNING | Function strftime() is deprecated since PHP 8.1 1372 | WARNING | Function gmstrftime() is deprecated since PHP 8.1 1372 | WARNING | Function strftime() is deprecated since PHP 8.1 1384 | WARNING | Function gmstrftime() is deprecated since PHP 8.1 1386 | WARNING | Function gmstrftime() is deprecated since PHP 8.1 ------------------------------------------------------------------------------------------------------------------------------------------------------ 

Environment

  • ADOdb version: master
  • Driver or Module: N/A
  • Database type and version: N/A
  • PHP version: 8.1+
  • Platform: N/A
  • I have tested that the problem is reproducible in the master branch

Steps to reproduce

Call the adodb_strftime() function without the ADODB_TEST_DATES constant defined and with an empty global $ADODB_DATE_LOCALE variable.

Expected behavior

Additional context

Add any other information relevant to the problem here.

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью