Commit a3a82686 authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic
Browse files

Bug 1811034: Upgrade ADODB to 5.20.14



behatnotneeded

Change-Id: I17a2c50f0d6be15a4d00a1917895c3908a60b02c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 20f76ffc)
parent 1905862c
adodb
-----
Website: http://adodb.sourceforge.net/
Version: 5.20.9
Website: http://adodb.org/
Version: 5.20.14
Modifications:
......
......@@ -5,11 +5,14 @@ ADOdb Library for PHP5
[![Download ADOdb](https://img.shields.io/sourceforge/dm/adodb.svg)](https://sourceforge.net/projects/adodb/files/latest/download)
(c) 2000-2013 John Lim (jlim@natsoft.com)
(c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both [BSD 3-Clause](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#bsd-3-clause-license)
and [GNU Lesser GPL library 2.1](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#gnu-lesser-general-public-license)
licenses.
(c) 2014 Damien Regad, Mark Newnham and the
[ADOdb community](https://github.com/ADOdb/ADOdb/graphs/contributors)
The ADOdb Library is dual-licensed, released under both the
[BSD 3-Clause](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#bsd-3-clause-license)
and the
[GNU Lesser General Public Licence (LGPL) v2.1](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#gnu-lesser-general-public-license)
or, at your option, any later version.
This means you can use it in proprietary products;
see [License](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md) for details.
......
<?php
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Latest version is available at http://adodb.sourceforge.net
Latest version is available at http://adodb.org/
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
......
<?php
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Latest version is available at http://adodb.sourceforge.net
Latest version is available at http://adodb.org/
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
......
......@@ -8,7 +8,7 @@ $ADODB_INCLUDED_CSV = 1;
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......@@ -16,14 +16,10 @@ $ADODB_INCLUDED_CSV = 1;
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Latest version is available at http://adodb.org/
Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format.
==== NOTE ====
Format documented at http://php.weblogs.com/ADODB_CSV
==============
*/
/**
......
<?php
/**
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......
<?php
/**
* @version v5.20.9 21-Dec-2016
* @version v5.20.14 06-Jan-2019
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
......
<?php
/**
* @version v5.20.9 21-Dec-2016
* @version v5.20.14 06-Jan-2019
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
......@@ -9,7 +9,7 @@
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
* Latest version is available at http://adodb.org/
*
*/
......
<?php
/**
* @version v5.20.9 21-Dec-2016
* @version v5.20.14 06-Jan-2019
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
......@@ -9,7 +9,7 @@
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
* Latest version is available at http://adodb.org/
*
*/
include_once('PEAR.php');
......
<?php
/**
* @version v5.20.9 21-Dec-2016
* @version v5.20.14 06-Jan-2019
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
......@@ -10,7 +10,7 @@
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
* Latest version is available at http://adodb.org/
*
* Exception-handling code using PHP5 exceptions (try-catch-throw).
*/
......
<?php
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......
......@@ -6,7 +6,7 @@ global $ADODB_INCLUDED_LIB;
$ADODB_INCLUDED_LIB = 1;
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......@@ -218,6 +218,13 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
{
$hasvalue = false;
if (is_array($name))
{
/*
* Reserved for future use
*/
}
if ($multiple or is_array($defstr)) {
if ($size==0) $size=5;
$attr = ' multiple size="'.$size.'"';
......@@ -227,12 +234,15 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
$s = '<select name="'.$name.'"'.$attr.' '.$selectAttr.'>';
if ($blank1stItem)
{
if (is_string($blank1stItem)) {
$barr = explode(':',$blank1stItem);
if (sizeof($barr) == 1) $barr[] = '';
$s .= "\n<option value=\"".$barr[0]."\">".$barr[1]."</option>";
} else $s .= "\n<option></option>";
}
else
$s .= "\n<option></option>";
}
if ($zthis->FieldCount() > 1) $hasvalue=true;
else $compareFields0 = true;
......@@ -248,34 +258,21 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
continue;
}
$myFields = array_map('trim',array_values($zthis->fields));
if ($fieldsize > 1) {
if (isset($zthis->fields[1]))
$zval2 = rtrim($zthis->fields[1]);
if (isset($myFields[1]))
$zval2 = $myFields[1];
else
$zval2 = rtrim(next($zthis->fields));
$zval2 = next($myFields);
}
$selected = ($compareFields0) ? $zval : $zval2;
$group = '';
if ($fieldsize > 2) {
$group = rtrim($zthis->fields[2]);
}
/*
if ($optgroup != $group) {
$optgroup = $group;
if ($firstgroup) {
$firstgroup = false;
$s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
} else {
$s .="\n</optgroup>";
$s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
}
}
*/
if ($hasvalue)
$value = " value='".htmlspecialchars($zval2)."'";
if (is_array($defstr)) {
if (is_array($defstr))
{
if (in_array($selected,$defstr))
$s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
......@@ -291,10 +288,6 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
$zthis->MoveNext();
} // while
// closing last optgroup
if($optgroup != null) {
$s .= "\n</optgroup>";
}
return $s ."\n</select>\n";
}
......@@ -304,6 +297,13 @@ function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multipl
{
$hasvalue = false;
if (is_array($name))
{
/*
* Reserved for future use
*/
}
if ($multiple or is_array($defstr)) {
if ($size==0) $size=5;
$attr = ' multiple size="'.$size.'"';
......@@ -334,17 +334,21 @@ function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multipl
continue;
}
$myFields = array_map('trim',array_values($zthis->fields));
if ($fieldsize > 1) {
if (isset($zthis->fields[1]))
$zval2 = rtrim($zthis->fields[1]);
if (isset($myFields[1]))
$zval2 = $myFields[1];
else
$zval2 = rtrim(next($zthis->fields));
$zval2 = next($myFields);
}
$selected = ($compareFields0) ? $zval : $zval2;
$group = '';
if (isset($zthis->fields[2])) {
$group = rtrim($zthis->fields[2]);
if (isset($myFields[2])) {
$group = $myFields[2];
}
if ($optgroup != $group) {
......@@ -384,7 +388,6 @@ function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multipl
return $s ."\n</select>\n";
}
/*
Count the number of records this sql statement will return by using
query rewriting heuristics...
......@@ -416,7 +419,12 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
} else
$rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")";
} else if (strncmp($zthis->databaseType,'postgres',8) == 0 || strncmp($zthis->databaseType,'mysql',5) == 0) {
} else if (strncmp($zthis->databaseType,'postgres',8) == 0
|| strncmp($zthis->databaseType,'mysql',5) == 0
|| strncmp($zthis->databaseType,'mssql',5) == 0
|| strncmp($zthis->dsnType,'sqlsrv',5) == 0
|| strncmp($zthis->dsnType,'mssql',5) == 0
){
$rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_";
} else {
$rewritesql = "SELECT COUNT(*) FROM ($rewritesql)";
......@@ -766,7 +774,7 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard));
else if (preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard));
else preg_match('/\s.*(\) WHERE .*)/is', $whereClause[1], $discard); # see http://sourceforge.net/tracker/index.php?func=detail&aid=1379638&group_id=42718&atid=433976
else preg_match('/\s.*(\) WHERE .*)/is', $whereClause[1], $discard); # see https://sourceforge.net/p/adodb/bugs/37/
} else
$whereClause = array(false,false);
......
......@@ -11,7 +11,7 @@ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......@@ -19,7 +19,7 @@ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Latest version is available at http://adodb.org/
Usage:
......
<?php
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......
<?php
/**
* @version v5.20.9 21-Dec-2016
* @version v5.20.14 06-Jan-2019
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
......
<?php
/*
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
......
<?php
/*
ADOdb Date Library, part of the ADOdb abstraction library
Download: http://adodb.sourceforge.net/#download
@version v5.20.9 21-Dec-2016
Latest version is available at http://adodb.org/
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
......@@ -420,6 +421,9 @@ $ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2);
if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
if (!DEFINED('ADODB_FUTURE_DATE_CUTOFF_YEARS'))
DEFINE('ADODB_FUTURE_DATE_CUTOFF_YEARS',200);
function adodb_date_test_date($y1,$m,$d=13)
{
$h = round(rand()% 24);
......@@ -829,13 +833,23 @@ global $_month_table_normal,$_month_table_leaf;
function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
{
static $YRS;
global $_month_table_normal,$_month_table_leaf;
global $_month_table_normal,$_month_table_leaf, $_adodb_last_date_call_failed;
$_adodb_last_date_call_failed = false;
$d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd));
$_day_power = 86400;
$_hour_power = 3600;
$_min_power = 60;
$cutoffDate = time() + (60 * 60 * 24 * 365 * ADODB_FUTURE_DATE_CUTOFF_YEARS);
if ($d > $cutoffDate)
{
$d = $cutoffDate;
$_adodb_last_date_call_failed = true;
}
if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction
$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
......@@ -1460,3 +1474,16 @@ global $ADODB_DATE_LOCALE;
$ret = adodb_date($fmtdate, $ts, $is_gmt);
return $ret;
}
/**
* Returns the status of the last date calculation and whether it exceeds
* the limit of ADODB_FUTURE_DATE_CUTOFF_YEARS
*
* @return boolean
*/
function adodb_last_date_status()
{
global $_adodb_last_date_call_failed;
return $_adodb_last_date_call_failed;
}
......@@ -2,7 +2,7 @@
/*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://adodb.sourceforge.net
* Latest version is available at http://adodb.org/
*
* This is the main include file for ADOdb.
* Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
......@@ -14,7 +14,7 @@
/**
\mainpage
@version v5.20.9 21-Dec-2016
@version v5.20.14 06-Jan-2019
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
......@@ -29,9 +29,6 @@
Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access,
ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and
other databases via ODBC.
Latest Download at http://adodb.sourceforge.net/
*/
if (!defined('_ADODB_LAYER')) {
......@@ -231,7 +228,7 @@ if (!defined('_ADODB_LAYER')) {
/**
* ADODB version as a string.
*/
$ADODB_vers = 'v5.20.9 21-Dec-2016';
$ADODB_vers = 'v5.20.14 06-Jan-2019';
/**
* Determines whether recordset->RecordCount() is used.
......@@ -430,6 +427,7 @@ if (!defined('_ADODB_LAYER')) {
var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql
var $database = ''; /// Name of database to be used.
var $host = ''; /// The hostname of the database server
var $port = ''; /// The port of the database server
var $user = ''; /// The username which is used to connect to the database server.
private $password = ''; /// Password for the username. This is required for __wakeup
var $debug = false; /// if set to true will output sql statements
......@@ -631,6 +629,26 @@ if (!defined('_ADODB_LAYER')) {
return false;
}
/**
* Parses the hostname to extract the port.
* Overwrites $this->host and $this->port, only if a port is specified.
* The Hostname can be fully or partially qualified,
* ie: "db.mydomain.com:5432" or "ldaps://ldap.mydomain.com:636"
* Any specified scheme such as ldap:// or ldaps:// is maintained.
*/
protected function parseHostNameAndPort() {
$parsed_url = parse_url($this->host);
if (is_array($parsed_url) && isset($parsed_url['host']) && isset($parsed_url['port'])) {
if ( isset($parsed_url['scheme']) ) {
// If scheme is specified (ie: ldap:// or ldaps://, make sure we retain that.
$this->host = $parsed_url['scheme'] . "://" . $parsed_url['host'];
} else {
$this->host = $parsed_url['host'];
}
$this->port = $parsed_url['port'];
}
}
/**
* Connect to database
*
......@@ -646,9 +664,9 @@ if (!defined('_ADODB_LAYER')) {
if ($argHostname != "") {
$this->host = $argHostname;
}
if ( strpos($this->host, ':') > 0 && isset($this->port) ) {
list($this->host, $this->port) = explode(":", $this->host, 2);
}
// Overwrites $this->host and $this->port if a port is specified.
$this->parseHostNameAndPort();
if ($argUsername != "") {
$this->user = $argUsername;
}
......@@ -729,9 +747,9 @@ if (!defined('_ADODB_LAYER')) {
if ($argHostname != "") {
$this->host = $argHostname;
}
if ( strpos($this->host, ':') > 0 && isset($this->port) ) {
list($this->host, $this->port) = explode(":", $this->host, 2);
}
// Overwrites $this->host and $this->port if a port is specified.
$this->parseHostNameAndPort();
if ($argUsername != "") {
$this->user = $argUsername;
}
......@@ -1162,8 +1180,7 @@ if (!defined('_ADODB_LAYER')) {
foreach($inputarr as $arr) {
$sql = ''; $i = 0;
//Use each() instead of foreach to reduce memory usage -mikefedyk
while(list(, $v) = each($arr)) {
foreach ($arr as $v) {
$sql .= $sqlarr[$i];
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types
......@@ -1496,6 +1513,9 @@ if (!defined('_ADODB_LAYER')) {
* @return the recordset ($rs->databaseType == 'array')
*/
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) {
$nrows = (int)$nrows;
$offset = (int)$offset;
if ($this->hasTop && $nrows > 0) {
// suggested by Reinhard Balling. Access requires top after distinct
// Informix requires first before distinct - F Riosa
......@@ -1510,7 +1530,7 @@ if (!defined('_ADODB_LAYER')) {
// access includes ties in result
if ($isaccess) {
$sql = preg_replace(
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql);
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
if ($secs2cache != 0) {
$ret = $this->CacheExecute($secs2cache, $sql,$inputarr);
......@@ -1520,10 +1540,10 @@ if (!defined('_ADODB_LAYER')) {
return $ret; // PHP5 fix
} else if ($ismssql){
$sql = preg_replace(
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql);
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
} else {
$sql = preg_replace(
'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql);
'/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
}
} else {
$nn = $nrows + $offset;
......@@ -2391,6 +2411,7 @@ if (!defined('_ADODB_LAYER')) {
*/
function Close() {
$rez = $this->_close();
$this->_queryID = false;
$this->_connectionID = false;
return $rez;
}
......@@ -3038,6 +3059,61 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $rs;
}
/**
* Get the last error recorded by PHP and clear the message.
*
* By clearing the message, it becomes possible to detect whether a new error
* has occurred, even when it is the same error as before being repeated.
*
* @return array|null Array if an error has previously occurred. Null otherwise.
*/
protected function resetLastError() {
$error = error_get_last();
if (is_array($error)) {
$error['message'] = '';
}
return $error;
}
/**
* Compare a previously stored error message with the last error recorded by PHP
* to determine whether a new error has occured.
*
* @param array|null $old Optional. Previously stored return value of error_get_last().
*
* @return string The error message if a new error has occured
* or an empty string if no (new) errors have occured..
*/
protected function getChangedErrorMsg($old = null) {
$new = error_get_last();
if (is_null($new)) {
// No error has occured yet at all.