Skip to content

Commit

Permalink
[BUGFIX] Prevent PHP 8 warning in ContentObjectRenderer
Browse files Browse the repository at this point in the history
This change prevents a PHP warning in ContentObjectRenderer
when working with "max" and "begin".

Resolves: #100857
Releases: main, 12.4, 11.5
Change-Id: I1af115deecc537efdc41125daa119630d6449044
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79549
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Jul 3, 2023
1 parent 15c7552 commit f2d8e0e
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -6084,21 +6084,27 @@ public function getQuery($table, $conf, $returnQueryArray = false)

try {
$count = $countQueryBuilder->executeQuery()->fetchOne();
$conf['max'] = str_ireplace('total', $count, $conf['max']);
$conf['begin'] = str_ireplace('total', $count, $conf['begin']);
if (isset($conf['max'])) {
$conf['max'] = str_ireplace('total', $count, (string)$conf['max']);
}
if (isset($conf['begin'])) {
$conf['begin'] = str_ireplace('total', $count, (string)$conf['begin']);
}
} catch (DBALException $e) {
$this->getTimeTracker()->setTSlogMessage($e->getPrevious()->getMessage());
$error = true;
}
}

if (!$error) {
$conf['begin'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['begin'] ?? '')), 0);
$conf['max'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['max'] ?? '')), 0);
if ($conf['begin'] > 0) {
if (isset($conf['begin']) && $conf['begin'] > 0) {
$conf['begin'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['begin'])), 0);
$queryBuilder->setFirstResult($conf['begin']);
}
$queryBuilder->setMaxResults($conf['max'] ?: 100000);
if (isset($conf['max'])) {
$conf['max'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['max'])), 0);
$queryBuilder->setMaxResults($conf['max'] ?: 100000);
}
}
}

Expand Down

0 comments on commit f2d8e0e

Please sign in to comment.