MDL-84401 libraries: upgrade to version 5.22.8 of ADOdb.

This commit is contained in:
Paul Holden 2025-02-05 22:48:42 +00:00
parent 139a0ad5f0
commit 2fe3e4c066
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
13 changed files with 194 additions and 80 deletions

View File

@ -1055,10 +1055,10 @@ class ADODB_Active_Record {
$valarr = array();
$neworig = array();
$pairs = array();
$i = -1;
$i = 0;
$cnt = 0;
foreach($table->flds as $name=>$fld) {
$i += 1;
$orig = $this->_original[$i++] ?? null;
$val = $this->$name;
$neworig[] = $val;
@ -1078,11 +1078,7 @@ class ADODB_Active_Record {
}
}
if (isset($this->_original[$i]) && strcmp($val,$this->_original[$i]) == 0) {
continue;
}
if (is_null($this->_original[$i]) && is_null($val)) {
if ($val === $orig) {
continue;
}

View File

@ -1142,10 +1142,10 @@ class ADODB_Active_Record {
$valarr = array();
$neworig = array();
$pairs = array();
$i = -1;
$i = 0;
$cnt = 0;
foreach($table->flds as $name=>$fld) {
$i += 1;
$orig = $this->_original[$i++] ?? null;
$val = $this->$name;
$neworig[] = $val;
@ -1165,7 +1165,7 @@ class ADODB_Active_Record {
}
}
if (isset($this->_original[$i]) && $val === $this->_original[$i]) {
if ($val === $orig) {
continue;
}
$valarr[] = $val;

View File

@ -510,10 +510,12 @@ class ADODB_DataDict {
*
* As some DBMs can't do that on their own, you need to supply the complete definition of the new table,
* to allow recreating the table and copying the content over to the new table
* @param string $tabname table-name
* @param string $flds column-name and type for the changed column
* @param string $tableflds='' complete definition of the new table, eg. for postgres, default ''
*
* @param string $tabname table-name
* @param array|string $flds column-name and type for the changed column
* @param string $tableflds='' complete definition of the new table, eg. for postgres, default ''
* @param array|string $tableoptions='' options for the new table see createTableSQL, default ''
*
* @return array with SQL strings
*/
function alterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
@ -1027,7 +1029,6 @@ class ADODB_DataDict {
function changeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false)
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($this->connection->fetchMode !== false) $savem = $this->connection->setFetchMode(false);
@ -1045,12 +1046,15 @@ class ADODB_DataDict {
return $this->createTableSQL($tablename, $flds, $tableoptions);
}
$sql = [];
if (is_array($flds)) {
// Cycle through the update fields, comparing
// existing fields to fields to update.
// if the Metatype and size is exactly the
// same, ignore - by Mark Newham
$holdflds = array();
$fields_to_add = [];
$fields_to_alter = [];
foreach($flds as $k=>$v) {
if ( isset($cols[$k]) && is_object($cols[$k]) ) {
// If already not allowing nulls, then don't change
@ -1074,15 +1078,20 @@ class ADODB_DataDict {
if ($mt == 'X') $ml = $v['SIZE'];
if (($mt != $v['TYPE']) || ($ml != $fsize || $sc != $fprec) || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) {
$holdflds[$k] = $v;
$fields_to_alter[$k] = $v;
}
} else {
$fields_to_add[$k] = $v;
$holdflds[$k] = $v;
}
}
$flds = $holdflds;
}
$sql = $this->alterColumnSql($tablename, $flds);
$sql = array_merge(
$this->addColumnSQL($tablename, $fields_to_add),
$this->alterColumnSql($tablename, $fields_to_alter)
);
}
if ($dropOldFlds) {
foreach ($cols as $id => $v) {

View File

@ -366,7 +366,7 @@ function _adodb_getmenu_select($name, $defstr = '', $blank1stItem = true,
function _adodb_getmenu_option($defstr, $compare, $value, $display)
{
if ( is_array($defstr) && in_array($compare, $defstr)
|| !is_array($defstr) && strcasecmp($compare, $defstr) == 0
|| !is_array($defstr) && strcasecmp($compare, $defstr ?? '') == 0
) {
$selected = ' selected="selected"';
} else {
@ -376,18 +376,23 @@ function _adodb_getmenu_option($defstr, $compare, $value, $display)
return "\n<option $value$selected>" . htmlspecialchars($display) . '</option>';
}
/*
Count the number of records this sql statement will return by using
query rewriting heuristics...
Does not work with UNIONs, except with postgresql and oracle.
Usage:
$conn->Connect(...);
$cnt = _adodb_getcount($conn, $sql);
*/
/**
* Count the number of records this sql statement will return by using
* query rewriting heuristics...
*
* Does not work with UNIONs, except with postgresql and oracle.
*
* Usage:
* $conn->Connect(...);
* $cnt = _adodb_getcount($conn, $sql);
*
* @param ADOConnection $zthis
* @param string $sql
* @param bool $inputarr
* @param int $secs2cache
*
* @return false|int|mixed
*/
function _adodb_getcount($zthis, $sql,$inputarr=false,$secs2cache=0)
{
$qryRecs = 0;
@ -1381,7 +1386,7 @@ function _adodb_backtrace($printOrArr=true, $maximumDepth=9999, $elementsToIgnor
$s .= '</pre>';
}
if ($printOrArr) {
print $s;
ADOConnection::outp($s);
}
return $s;

View File

@ -198,7 +198,7 @@ if (!defined('_ADODB_LAYER')) {
/**
* ADODB version as a string.
*/
$ADODB_vers = 'v5.22.7 2023-11-04';
$ADODB_vers = 'v5.22.8 2025-01-25';
/**
* Determines whether recordset->RecordCount() is used.
@ -4300,6 +4300,8 @@ class ADORecordSet implements IteratorAggregate {
*/
function getAssoc($force_array = false, $first2cols = false)
{
global $ADODB_FETCH_MODE;
/*
* Insufficient rows to show data
*/
@ -4322,8 +4324,8 @@ class ADORecordSet implements IteratorAggregate {
* Get the fetch mode when the call was executed, this may be
* different than ADODB_FETCH_MODE
*/
$fetchMode = $this->connection->fetchMode;
if ($fetchMode == ADODB_FETCH_BOTH) {
$fetchMode = $this->adodbFetchMode;
if ($fetchMode == ADODB_FETCH_BOTH || $fetchMode == ADODB_FETCH_DEFAULT) {
/*
* If we are using BOTH, we present the data as if it
* was in ASSOC mode. This could be enhanced by adding
@ -4355,7 +4357,7 @@ class ADORecordSet implements IteratorAggregate {
$myFields = $this->fields;
if ($fetchMode == ADODB_FETCH_BOTH) {
if ($fetchMode == ADODB_FETCH_BOTH || $fetchMode == ADODB_FETCH_DEFAULT) {
/*
* extract the associative keys
*/

View File

@ -109,10 +109,12 @@ class ADODB_db2 extends ADOConnection {
return null;
}
$connectionParameters = $this->unpackParameters($argDSN,
$argUsername,
$argPassword,
$argDatabasename);
$connectionParameters = $this->unpackParameters(
$argDSN,
$argUsername,
$argPassword,
$argDatabasename
);
if ($connectionParameters == null)
{
@ -129,7 +131,12 @@ class ADODB_db2 extends ADOConnection {
$useCataloguedConnection = $connectionParameters['catalogue'];
if ($this->debug){
if ($useCataloguedConnection){
if (strcmp($argDSN,'*LOCAL') == 0)
{
$connectMessage = '*LOCAL connection';
}
else if ($useCataloguedConnection)
{
$connectMessage = "Catalogued connection using parameters: ";
$connectMessage .= "DB=$argDatabasename / ";
$connectMessage .= "UID=$argUsername / ";
@ -141,6 +148,7 @@ class ADODB_db2 extends ADOConnection {
}
ADOConnection::outp($connectMessage);
}
/*
* This needs to be set before the connect().
*/
@ -164,14 +172,17 @@ class ADODB_db2 extends ADOConnection {
}
if ($useCataloguedConnection)
{
$this->_connectionID = $db2Function($argDatabasename,
$argUsername,
$argPassword,
$db2Options);
}
else
$this->_connectionID = $db2Function($argDSN,
null,
null,
'',
'',
$db2Options);
@ -180,6 +191,9 @@ class ADODB_db2 extends ADOConnection {
if ($this->_connectionID && $this->connectStmt)
$this->execute($this->connectStmt);
if ($this->_connectionID && $argDatabasename)
$this->execute("SET SCHEMA=$argDatabasename");
return $this->_connectionID != false;
}
@ -198,12 +212,25 @@ class ADODB_db2 extends ADOConnection {
{
$connectionParameters = array('dsn'=>'',
'uid'=>'',
'pwd'=>'',
'database'=>'',
'catalogue'=>true
);
$connectionParameters = array(
'dsn'=>'',
'uid'=>'',
'pwd'=>'',
'database'=>'',
'catalogue'=>true
);
/*
* Shortcut for *LOCAL
*/
if (strcmp($argDSN,'*LOCAL') == 0)
{
$connectionParameters['dsn'] = $argDSN;
$connectionParameters['database'] = $argDatabasename;
$connectionParameters['catalogue'] = false;
return $connectionParameters;
}
/*
* Uou can either connect to a catalogued connection

View File

@ -76,7 +76,7 @@ class ADODB_ldap extends ADOConnection {
if ($this->debug) ADOConnection::outp($e);
return false;
}
if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) {
if(!empty($LDAP_CONNECT_OPTIONS)) {
$this->_inject_bind_options( $LDAP_CONNECT_OPTIONS );
}

View File

@ -75,6 +75,25 @@ class ADODB_mysqli extends ADOConnection {
var $ssl_capath = null;
var $ssl_cipher = null;
/**
* Forcing emulated prepared statements.
*
* When set to true, ADODb will not execute queries using MySQLi native
* bound variables, and will instead use the built-in string interpolation
* and argument quoting from the parent class {@see ADOConnection::Execute()}.
*
* This is needed for some database engines that use mysql wire-protocol but
* do not support prepared statements, like
* {@see https://manticoresearch.com/ Manticore Search} or
* {@see https://clickhouse.com/ ClickHouse}.
*
* WARNING: This is a potential security risk, and strongly discouraged for code
* handling untrusted input {@see https://github.com/ADOdb/ADOdb/issues/1028#issuecomment-2081586024}.
*
* @var bool $doNotUseBoundVariables
*/
var $doNotUseBoundVariables = false;
/** @var mysqli Identifier for the native database connection */
var $_connectionID = false;
@ -126,22 +145,74 @@ class ADODB_mysqli extends ADOConnection {
}
/**
* Adds a parameter to the connection string.
* Adds a parameter to the connection string, can also set connection property values.
*
* Parameter must be one of the constants listed in mysqli_options().
* @see https://www.php.net/manual/en/mysqli.options.php
*
* @param int $parameter The parameter to set
* @param string $value The value of the parameter
*
* OR
*
* Parameter must be a string matching one of the following special cases.
* 'ssl' - SSL values e.g. ('ssl' => ['ca' => '/path/to/ca.crt.pem'])
* 'clientflags' - Client flags of type 'MYSQLI_CLIENT_'
* @see https://www.php.net/manual/en/mysqli.real-connect.php
* @see https://www.php.net/manual/en/mysqli.constants.php
* 'socket' - The socket or named pipe that should be used
* 'port' - The port number to attempt to connect to the MySQL server
*
* @param string|int $parameter The parameter to set
* @param string|int|array $value The value of the parameter
*
* @return bool
*/
public function setConnectionParameter($parameter, $value) {
if(!is_numeric($parameter)) {
$this->outp_throw("Invalid connection parameter '$parameter'", __METHOD__);
return false;
// Special case for setting SSL values.
if ("ssl" === $parameter && is_array($value)) {
if (isset($value["key"])) {
$this->ssl_key = $value["key"];
}
if (isset($value["cert"])) {
$this->ssl_cert = $value["cert"];
}
if (isset($value["ca"])) {
$this->ssl_ca = $value["ca"];
}
if (isset($value["capath"])) {
$this->ssl_capath = $value["capath"];
}
if (isset($value["cipher"])) {
$this->ssl_cipher = $value["cipher"];
}
return true;
}
return parent::setConnectionParameter($parameter, $value);
// Special case for setting the client flag(s).
if ("clientflags" === $parameter && is_numeric($value)) {
$this->clientFlags = $value;
return true;
}
// Special case for setting the socket.
if ("socket" === $parameter && is_string($value)) {
$this->socket = $value;
return true;
}
// Special case for setting the port.
if ("port" === $parameter && is_numeric($value)) {
$this->port = (int)$value;
return true;
}
// Standard mysqli_options.
if (is_numeric($parameter)) {
return parent::setConnectionParameter($parameter, $value);
}
$this->outp_throw("Invalid connection parameter '$parameter'", __METHOD__);
return false;
}
/**
@ -214,9 +285,14 @@ class ADODB_mysqli extends ADOConnection {
// SSL Connections for MySQLI
if ($this->ssl_key || $this->ssl_cert || $this->ssl_ca || $this->ssl_capath || $this->ssl_cipher) {
mysqli_ssl_set($this->_connectionID, $this->ssl_key, $this->ssl_cert, $this->ssl_ca, $this->ssl_capath, $this->ssl_cipher);
$this->socket = MYSQLI_CLIENT_SSL;
$this->clientFlags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
// Check for any SSL client flag set, NOTE: bitwise operation.
if (!($this->clientFlags & MYSQLI_CLIENT_SSL)) {
ADOConnection::outp('When using certificates, set the client flag MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT or MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT');
return false;
}
}
#if (!empty($this->port)) $argHostname .= ":".$this->port;
@ -944,9 +1020,11 @@ class ADODB_mysqli extends ADOConnection {
AND table_name='$table'";
$schemaArray = $this->getAssoc($SQL);
$schemaArray = array_change_key_case($schemaArray,CASE_LOWER);
if (is_array($schemaArray)) {
$schemaArray = array_change_key_case($schemaArray,CASE_LOWER);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
}
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs))
@ -1101,6 +1179,10 @@ class ADODB_mysqli extends ADOConnection {
public function execute($sql, $inputarr = false)
{
if ($this->doNotUseBoundVariables) {
return parent::execute($sql, $inputarr);
}
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret = $fn($this, $sql, $inputarr);

View File

@ -1576,11 +1576,8 @@ SELECT /*+ RULE */ distinct b.column_name
*/
function qStr($s, $magic_quotes=false)
{
if ($this->noNullStrings && strlen($s) == 0) {
$s = ' ';
}
else if (strlen($s) == 0) {
return "''";
if (strlen((string)$s) == 0) {
return $this->noNullStrings ? "' '" : "''";
}
if ($this->replaceQuote[0] == '\\'){
$s = str_replace('\\','\\\\',$s);

View File

@ -113,13 +113,12 @@ class ADODB_postgres64 extends ADOConnection{
}
$version = pg_version($this->_connectionID);
// If PHP has been compiled with PostgreSQL 7.3 or lower, then
// server_version is not set so we use pg_parameter_status() instead.
$version_server = $version['server'] ?? pg_parameter_status($this->_connectionID, 'server_version');
$this->version = array(
// If PHP has been compiled with PostgreSQL 7.3 or lower, then
// server version is not set so we use pg_parameter_status()
// which includes logic to obtain values server_version
'version' => isset($version['server'])
? $version['server']
: pg_parameter_status($this->_connectionID, 'server_version'),
'version' => $this->_findvers($version_server),
'client' => $version['client'],
'description' => null,
);

View File

@ -14,11 +14,8 @@ Removed:
* lang/* everything but adodb-en.inc.php (originally because they were not utf-8, now because of not used)
* nbproject/ (if present)
* pear/
* replicate/ (if present)
* scripts/ (if present)
* server.php (if present)
* session/
* tests/ (if present)
Added:
* index.html - prevent directory browsing on misconfigured servers

View File

@ -107,9 +107,9 @@ function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
if ($hasNumIndex) {
for ($j=0; $j < $max; $j++) {
$v = $rs->fields[$j];
if (!is_object($v)) $v = trim($v);
if (!is_object($v)) $v = trim((string)$v);
else $v = 'Object';
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
if ($escquote) $v = str_replace($quote,$escquotequote,(string)$v);
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
@ -117,8 +117,8 @@ function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
}
} else { // ASSOCIATIVE ARRAY
foreach($rs->fields as $v) {
if ($escquote) $v = str_replace($quote,$escquotequote,trim($v));
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
if ($escquote) $v = str_replace($quote,$escquotequote,trim((string)$v));
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,(string)$v))));
if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
else $elements[] = $v;

View File

@ -2,9 +2,9 @@
<libraries>
<library>
<location>adodb</location>
<name>AdoDB</name>
<name>ADOdb</name>
<description>Database abstraction library for MySQL, PostgreSQL, MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 and ODBC.</description>
<version>5.22.7</version>
<version>5.22.8</version>
<license>BSD/LGPL</license>
<licenseversion>3-Clause/2.1+</licenseversion>
<repository>https://github.com/ADOdb/ADOdb</repository>