Skip to content

Commit

Permalink
Prevent queries if pagination is deactivated (#2493)
Browse files Browse the repository at this point in the history
* [Bugfix] Constructor in subsequent proxyclasses

The constructorLines property is never unsetted in ClassCacheManager.
This results in added constructors for subsequent classes if this
property is set.

Resetting this property to an empty array fixes this issue.

* Do not execute SQL queries for paginator, if pagination is disabled

---------

Co-authored-by: markus <[email protected]>
Co-authored-by: Stefan Frömken <[email protected]>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent 8dbf2be commit 4fd1206
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Classes/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,22 @@ public function listAction(?array $overwriteDemand = null): ResponseInterface
$this->view->assignMultiple($event->getAssignedValues());

// pagination
$paginationConfiguration = $this->settings['list']['paginate'] ?? [];
$itemsPerPage = (int)(($paginationConfiguration['itemsPerPage'] ?? '') ?: 10);
$maximumNumberOfLinks = (int)($paginationConfiguration['maximumNumberOfLinks'] ?? 0);
if ((int)($this->settings['hidePagination'] ?? 0) === 0) {
$paginationConfiguration = $this->settings['list']['paginate'] ?? [];
$itemsPerPage = (int)(($paginationConfiguration['itemsPerPage'] ?? '') ?: 10);
$maximumNumberOfLinks = (int)($paginationConfiguration['maximumNumberOfLinks'] ?? 0);

$currentPage = max(1, $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1);
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $event->getAssignedValues()['news'], $currentPage, $itemsPerPage, (int)($this->settings['limit'] ?? 0), (int)($this->settings['offset'] ?? 0));
$paginationClass = $paginationConfiguration['class'] ?? SimplePagination::class;
$pagination = $this->getPagination($paginationClass, $maximumNumberOfLinks, $paginator);
$currentPage = max(1, $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1);
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $event->getAssignedValues()['news'], $currentPage, $itemsPerPage, (int)($this->settings['limit'] ?? 0), (int)($this->settings['offset'] ?? 0));
$paginationClass = $paginationConfiguration['class'] ?? SimplePagination::class;
$pagination = $this->getPagination($paginationClass, $maximumNumberOfLinks, $paginator);

$this->view->assign('pagination', [
'currentPage' => $currentPage,
'paginator' => $paginator,
'pagination' => $pagination,
]);
$this->view->assign('pagination', [
'currentPage' => $currentPage,
'paginator' => $paginator,
'pagination' => $pagination,
]);
}

Cache::addPageCacheTagsByDemandObject($demand);
return $this->htmlResponse();
Expand Down

0 comments on commit 4fd1206

Please sign in to comment.