ADOdb / ADOdb

ADOdb is a PHP database class library that provides powerful abstractions for performing queries and managing databases. ADOdb also hides the differences between DB engines so you can easily switch them without changing your code.
https://adodb.org/
Other
421 stars 268 forks source link

oci8: Prevent str_replace NULL error in qstr() methods on PHP 8.1 #999

Closed wesyah234 closed 8 months ago

wesyah234 commented 11 months ago

Description adodb-oci8.inc.php:1585 str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Environment ADOdb version: 5.22.6 Driver or Module: oci8 PHP version: 8.2 Platform: linux

Solved by changing:

    return  "'" . str_replace("'", $this->replaceQuote, $s) . "'";

to: return "'" . str_replace("'", $this->replaceQuote, $s ?? '') . "'";

Thanks!

wesyah234 commented 7 months ago

This method is still giving me trouble. I'm using v5.22.7 now, and I get this error:

adodb-php/drivers/adodb-oci8.inc.php:1582 strlen(): Passing null to parameter #1 ($string) of type string is deprecated

the strlen check you put in has the same issue as the str_replace, in that it's not happy when $s is null, so now the issue is showing up in the: else if (strlen($s) == 0) { return "''"; }

and it's addressed by changing it to else if (strlen($s ?? '') == 0) { return "''"; }