Skip to content

Commit 62e6a9a

Browse files
committed
Bump ADOdb to v5.22.6.
1 parent 89dfcef commit 62e6a9a

35 files changed

+253
-150
lines changed

libraries/adodb/adodb-csvlib.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
7676

7777
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
7878
$class = $rs->connection->arrayClass;
79+
/** @var ADORecordSet $rs2 */
7980
$rs2 = new $class(ADORecordSet::DUMMY_QUERY_ID);
8081
$rs2->timeCreated = $rs->timeCreated; # memcache fix
8182
$rs2->sql = $rs->sql;
82-
$rs2->oldProvider = $rs->dataProvider;
8383
$rs2->InitArrayFields($rows,$flds);
8484
$rs2->fetchMode = $savefetch;
8585
return $line.serialize($rs2);

libraries/adodb/adodb-exceptions.inc.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@ function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
8181

8282
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
8383
{
84-
global $ADODB_EXCEPTION;
84+
global $ADODB_EXCEPTION;
85+
86+
// Do not throw if errors are suppressed by @ operator
87+
// error_reporting() value for suppressed errors changed in PHP 8.0.0
88+
$suppressed = version_compare(PHP_VERSION, '8.0.0', '<')
89+
? 0
90+
: E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
91+
if (error_reporting() == $suppressed) {
92+
return;
93+
}
94+
95+
$errfn = is_string($ADODB_EXCEPTION) ? $ADODB_EXCEPTION : 'ADODB_EXCEPTION';
8596

86-
if (error_reporting() == 0) return; // obey @ protocol
87-
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
88-
else $errfn = 'ADODB_EXCEPTION';
8997
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
9098
}

libraries/adodb/adodb-lib.inc.php

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -508,32 +508,38 @@ function _adodb_getcount($zthis, $sql,$inputarr=false,$secs2cache=0)
508508
return $qryRecs;
509509
}
510510

511-
/*
512-
Code originally from "Cornel G" <[email protected]>
513-
514-
This code might not work with SQL that has UNION in it
515-
516-
Also if you are using CachePageExecute(), there is a strong possibility that
517-
data will get out of synch. use CachePageExecute() only with tables that
518-
rarely change.
519-
*/
520-
function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page,
521-
$inputarr=false, $secs2cache=0)
511+
/**
512+
* Execute query with pagination including record count.
513+
*
514+
* This code might not work with SQL that has UNION in it.
515+
* Also if you are using cachePageExecute(), there is a strong possibility that
516+
* data will get out of sync. cachePageExecute() should only be used with
517+
* tables that rarely change.
518+
*
519+
* @param ADOConnection $zthis Connection
520+
* @param string $sql Query to execute
521+
* @param int $nrows Number of rows per page
522+
* @param int $page Page number to retrieve (1-based)
523+
* @param array $inputarr Array of bind variables
524+
* @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
525+
*
526+
* @return ADORecordSet|bool
527+
*
528+
* @author Cornel G <[email protected]>
529+
*/
530+
function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
522531
{
523532
$atfirstpage = false;
524533
$atlastpage = false;
525534

526-
// If an invalid nrows is supplied,
527-
// we assume a default value of 10 rows per page
535+
// If an invalid nrows is supplied, assume a default value of 10 rows per page
528536
if (!isset($nrows) || $nrows <= 0) $nrows = 10;
529537

530538
$qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache);
531539
$lastpageno = (int) ceil($qryRecs / $nrows);
532-
$zthis->_maxRecordCount = $qryRecs;
533540

534-
// ***** Here we check whether $page is the last page or
535-
// whether we are trying to retrieve
536-
// a page number greater than the last page number.
541+
// Check whether $page is the last page or if we are trying to retrieve
542+
// a page number greater than the last one.
537543
if ($page >= $lastpageno) {
538544
$page = $lastpageno;
539545
$atlastpage = true;
@@ -565,7 +571,25 @@ function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page,
565571
return $rsreturn;
566572
}
567573

568-
// Iván Oliva version
574+
/**
575+
* Execute query with pagination without last page information.
576+
*
577+
* This code might not work with SQL that has UNION in it.
578+
* Also if you are using cachePageExecute(), there is a strong possibility that
579+
* data will get out of sync. cachePageExecute() should only be used with
580+
* tables that rarely change.
581+
*
582+
* @param ADOConnection $zthis Connection
583+
* @param string $sql Query to execute
584+
* @param int $nrows Number of rows per page
585+
* @param int $page Page number to retrieve (1-based)
586+
* @param array $inputarr Array of bind variables
587+
* @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
588+
*
589+
* @return ADORecordSet|bool
590+
*
591+
* @author Iván Oliva
592+
*/
569593
function _adodb_pageexecute_no_last_page($zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
570594
{
571595
$atfirstpage = false;

libraries/adodb/adodb-loadbalancer.inc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ class ADOdbLoadBalancer
3838
/**
3939
* @var bool|array All connections to each database.
4040
*/
41-
protected $connections = false;
41+
protected $connections = [];
4242

4343
/**
4444
* @var bool|array Just connections to the write capable database.
4545
*/
46-
protected $connections_write = false;
46+
protected $connections_write = [];
4747

4848
/**
4949
* @var bool|array Just connections to the readonly database.
5050
*/
51-
protected $connections_readonly = false;
51+
protected $connections_readonly = [];
5252

5353
/**
5454
* @var array Counts of all connections and their types.
@@ -73,12 +73,12 @@ class ADOdbLoadBalancer
7373
/**
7474
* @var bool Session variables that must be maintained across all connections, ie: SET TIME ZONE.
7575
*/
76-
protected $session_variables = false;
76+
protected $session_variables = [];
7777

7878
/**
7979
* @var bool Called immediately after connecting to any DB.
8080
*/
81-
protected $user_defined_session_init_sql = false;
81+
protected $user_defined_session_init_sql = [];
8282

8383

8484
/**
@@ -403,7 +403,7 @@ public function setSessionVariable($name, $value, $execute_immediately = true)
403403
*/
404404
private function executeSessionVariables($adodb_obj = false)
405405
{
406-
if (is_array($this->session_variables)) {
406+
if (is_array($this->session_variables) && count($this->session_variables) > 0) {
407407
$sql = '';
408408
foreach ($this->session_variables as $name => $value) {
409409
// $sql .= 'SET SESSION '. $name .' '. $value;

libraries/adodb/adodb-perf.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ function SplitSQL($sql)
10171017
* <code>ADODB_OPT_LOW</code> for CPU-less optimization
10181018
* Default is LOW <code>ADODB_OPT_LOW</code>
10191019
* @author Markus Staab
1020-
* @return Returns <code>true</code> on success and <code>false</code> on error
1020+
* @return bool true on success, false on error
10211021
*/
10221022
function OptimizeTables()
10231023
{
@@ -1048,7 +1048,7 @@ function OptimizeTables()
10481048
* <code>ADODB_OPT_LOW</code> for CPU-less optimization
10491049
* Default is LOW <code>ADODB_OPT_LOW</code>
10501050
* @author Markus Staab
1051-
* @return Returns <code>true</code> on success and <code>false</code> on error
1051+
* @return bool true on success, false on error
10521052
*/
10531053
function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
10541054
{
@@ -1062,7 +1062,7 @@ function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
10621062
* optimize each using <code>optmizeTable()</code>
10631063
*
10641064
* @author Markus Staab
1065-
* @return Returns <code>true</code> on success and <code>false</code> on error
1065+
* @return bool true on success, false on error
10661066
*/
10671067
function optimizeDatabase()
10681068
{

libraries/adodb/adodb-time.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/**
33
* ADOdb Date Library.
44
*
5+
* @deprecated 5.22.6 Use 64-bit PHP native functions instead.
6+
*
57
* PHP native date functions use integer timestamps for computations.
68
* Because of this, dates are restricted to the years 1901-2038 on Unix
79
* and 1970-2038 on Windows due to integer overflow for dates beyond

libraries/adodb/adodb-xmlschema.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function addData( $attributes ) {
412412
* @param string $type ADODB datadict field type.
413413
* @param string $size Field size
414414
* @param array $opts Field options array
415-
* @return array Field specifier array
415+
* @return void
416416
*/
417417
function addField( $name, $type, $size = NULL, $opts = NULL ) {
418418
$field_id = $this->FieldID( $name );
@@ -446,7 +446,7 @@ function addField( $name, $type, $size = NULL, $opts = NULL ) {
446446
* @param string $field Field name
447447
* @param string $opt ADOdb field option
448448
* @param mixed $value Field option value
449-
* @return array Field specifier array
449+
* @return void
450450
*/
451451
function addFieldOpt( $field, $opt, $value = NULL ) {
452452
if( !isset( $value ) ) {

libraries/adodb/adodb-xmlschema03.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function addData( $attributes ) {
450450
* @param string $type ADODB datadict field type.
451451
* @param string $size Field size
452452
* @param array $opts Field options array
453-
* @return array Field specifier array
453+
* @return void
454454
*/
455455
function addField( $name, $type, $size = NULL, $opts = NULL ) {
456456
$field_id = $this->fieldID( $name );
@@ -486,7 +486,7 @@ function addField( $name, $type, $size = NULL, $opts = NULL ) {
486486
* @param string $field Field name
487487
* @param string $opt ADOdb field option
488488
* @param mixed $value Field option value
489-
* @return array Field specifier array
489+
* @return void
490490
*/
491491
function addFieldOpt( $field, $opt, $value = NULL ) {
492492
if( $this->currentPlatform ) {
@@ -766,7 +766,7 @@ function _tag_close( $parser, $tag ) {
766766
* Adds a field to the index
767767
*
768768
* @param string $name Field name
769-
* @return string Field list
769+
* @return string[] Field list
770770
*/
771771
function addField( $name ) {
772772
$this->columns[$this->fieldID( $name )] = $name;
@@ -779,7 +779,7 @@ function addField( $name ) {
779779
* Adds options to the index
780780
*
781781
* @param string $opt Comma-separated list of index options.
782-
* @return string Option list
782+
* @return string[] Option list
783783
*/
784784
function addIndexOpt( $opt ) {
785785
$this->opts[] = $opt;
@@ -929,10 +929,10 @@ function addField( $attributes ) {
929929
}
930930

931931
/**
932-
* Adds options to the index
932+
* Adds data.
933933
*
934-
* @param string $opt Comma-separated list of index options.
935-
* @return string Option list
934+
* @param string $cdata Data to add
935+
* @return void
936936
*/
937937
function addData( $cdata ) {
938938
// check we're in a valid field
@@ -1782,7 +1782,7 @@ function saveSQL( $filename = './schema.sql' ) {
17821782
$sqlArray = $this->sqlArray;
17831783
}
17841784
if( !isset( $sqlArray ) ) {
1785-
return FALSE;
1785+
return false;
17861786
}
17871787

17881788
$fp = fopen( $filename, "w" );

libraries/adodb/adodb.inc.php

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function ADODB_Setup() {
198198
/**
199199
* ADODB version as a string.
200200
*/
201-
$ADODB_vers = 'v5.22.5 2023-04-03';
201+
$ADODB_vers = 'v5.22.6 2023-06-11';
202202

203203
/**
204204
* Determines whether recordset->RecordCount() is used.
@@ -1466,7 +1466,7 @@ function HasFailedTrans() {
14661466
* @param array|bool $inputarr holds the input data to bind to.
14671467
* Null elements will be set to null.
14681468
*
1469-
* @return ADORecordSet|bool
1469+
* @return ADORecordSet|false
14701470
*/
14711471
public function Execute($sql, $inputarr = false) {
14721472
if ($this->fnExecute) {
@@ -1666,6 +1666,18 @@ function _Execute($sql,$inputarr=false) {
16661666
return $rs;
16671667
}
16681668

1669+
/**
1670+
* Execute a query.
1671+
*
1672+
* @param string|array $sql Query to execute.
1673+
* @param array $inputarr An optional array of parameters.
1674+
*
1675+
* @return mixed|bool Query identifier or true if execution successful, false if failed.
1676+
*/
1677+
function _query($sql, $inputarr = false) {
1678+
return false;
1679+
}
1680+
16691681
function CreateSequence($seqname='adodbseq',$startID=1) {
16701682
if (empty($this->_genSeqSQL)) {
16711683
return false;
@@ -3554,20 +3566,21 @@ function qStr($s, $magic_quotes=false) {
35543566

35553567

35563568
/**
3557-
* Will select the supplied $page number from a recordset, given that it is paginated in pages of
3558-
* $nrows rows per page. It also saves two boolean values saying if the given page is the first
3559-
* and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
3569+
* Execute query with pagination.
35603570
*
3561-
* See docs-adodb.htm#ex8 for an example of usage.
3562-
* NOTE: phpLens uses a different algorithm and does not use PageExecute().
3571+
* Will select the supplied $page number from a recordset, divided in
3572+
* pages of $nrows rows each. It also saves two boolean values saying
3573+
* if the given page is the first and/or last one of the recordset.
35633574
*
3564-
* @param string $sql
3565-
* @param int $nrows Number of rows per page to get
3566-
* @param int $page Page number to get (1-based)
3567-
* @param mixed[]|bool $inputarr Array of bind variables
3568-
* @param int $secs2cache Private parameter only used by jlim
3575+
* @param string $sql Query to execute
3576+
* @param int $nrows Number of rows per page
3577+
* @param int $page Page number to retrieve (1-based)
3578+
* @param array|bool $inputarr Array of bind variables
3579+
* @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
3580+
*
3581+
* @return ADORecordSet|bool the recordset ($rs->databaseType == 'array')
35693582
*
3570-
* @return mixed the recordset ($rs->databaseType == 'array')
3583+
* @author Iván Oliva
35713584
*/
35723585
function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) {
35733586
global $ADODB_INCLUDED_LIB;
@@ -3743,6 +3756,7 @@ protected function getChangedErrorMsg($old = null) {
37433756
/**
37443757
* Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
37453758
*/
3759+
#[\AllowDynamicProperties]
37463760
class ADOFetchObj {
37473761
};
37483762

@@ -3982,11 +3996,20 @@ class ADORecordSet implements IteratorAggregate {
39823996
var $_obj; /** Used by FetchObj */
39833997
var $_names; /** Used by FetchObj */
39843998

3985-
var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */
3986-
var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */
3987-
var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */
3999+
// Recordset pagination
4000+
/** @var int Number of rows per page */
4001+
var $rowsPerPage;
4002+
/** @var int Current page number */
4003+
var $_currentPage = -1;
4004+
/** @var bool True if current page is the first page */
4005+
var $_atFirstPage = false;
4006+
/** @var bool True if current page is the last page */
4007+
var $_atLastPage = false;
4008+
/** @var int Last page number */
39884009
var $_lastPageNo = -1;
4010+
/** @var int Total number of rows in recordset */
39894011
var $_maxRecordCount = 0;
4012+
39904013
var $datetime = false;
39914014

39924015
public $customActualTypes;

0 commit comments

Comments
 (0)