Version 4.7.6

This commit is contained in:
Neo committed 2025-12-19 16:05:19 -08:00
1 parent 8ba7d43898
commit 7b7404e741
1085 files changed
+30590 -7837

No files matched your search

+12 -6
View File
@@ -64,7 +64,7 @@ class _PaginatedResponse extends Response
* @param \Iterator $iterator Select query or \IPS\Patterns\ActiveRecordIterator instance
* @param int $page Current page
* @param string $activeRecordClass ActiveRecord class
* @param int $count Total Count
* @param int|NULL $count Total Count
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @param int $perPage Number of results per page
* @return void
@@ -78,6 +78,17 @@ class _PaginatedResponse extends Response
$this->count = (int) $count;
$this->resultsPerPage = $perPage ? (int) $perPage : 25;
$this->authorizedMember = $authorizedMember;
if( $this->iterator instanceof \IPS\Db\Select )
{
/* Limit the query before calling count(), as this runs the query so it cannot be modified after */
$this->iterator->query .= \IPS\Db::i()->compileLimitClause( array( ( $this->page - 1 ) * $this->resultsPerPage, $this->resultsPerPage ) );
if ( $count === NULL )
{
$this->count = $iterator->count();
}
}
}
/**
@@ -89,11 +100,6 @@ class _PaginatedResponse extends Response
{
$results = array();
if( $this->iterator instanceof \IPS\Db\Select )
{
$this->iterator->query .= \IPS\Db::i()->compileLimitClause( array( ( $this->page - 1 ) * $this->resultsPerPage, $this->resultsPerPage ) );
}
if ( $this->activeRecordClass )
{
if( $this->iterator instanceof \IPS\Patterns\ActiveRecordIterator )