From 8b13518f2c29cab210b0a58c9d14328e5614ddec Mon Sep 17 00:00:00 2001 From: Kuno Tranelis Date: Fri, 16 Sep 2022 12:58:23 +0200 Subject: [PATCH 1/2] BUGFIX make pagination work with Traversable Warning: array_slice() expects parameter 1 to be array, object given in /tmp/Flow/Development/SubContextddev/Cache/Code/Flow_Object_Classes/Neos_ContentRepository_ViewHelpers_Widget_Controller_PaginateController.php line 124 --- .../ViewHelpers/Widget/Controller/PaginateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php b/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php index cf55154c41e..ff8e00a0841 100644 --- a/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php +++ b/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php @@ -121,7 +121,7 @@ public function indexAction($currentPage = 1) } $offset = ($this->currentPage > 1) ? (integer)($itemsPerPage * ($this->currentPage - 1)) : null; if ($this->parentNode === null) { - $nodes = array_slice($this->nodes, $offset, $itemsPerPage); + $nodes = (array) array_slice($this->nodes, $offset, $itemsPerPage); } else { $nodes = $this->parentNode->getChildNodes($this->nodeTypeFilter, $itemsPerPage, $offset); } From 0cc405c6fa7d71106518864cd37536f5ba48ab14 Mon Sep 17 00:00:00 2001 From: Kuno Tranelis Date: Mon, 17 Oct 2022 12:30:33 +0200 Subject: [PATCH 2/2] TASK: get array copy if ArrayIterator --- .../ViewHelpers/Widget/Controller/PaginateController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php b/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php index cf55154c41e..1d264fb9c02 100644 --- a/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php +++ b/Neos.ContentRepository/Classes/ViewHelpers/Widget/Controller/PaginateController.php @@ -11,6 +11,7 @@ * source code. */ +use ArrayIterator; use Neos\Utility\Arrays; use Neos\FluidAdaptor\Core\Widget\AbstractWidgetController; use Neos\ContentRepository\Domain\Model\NodeInterface; @@ -87,7 +88,11 @@ class PaginateController extends AbstractWidgetController protected function initializeAction() { $this->parentNode = $this->widgetConfiguration['parentNode']; - $this->nodes = $this->widgetConfiguration['nodes']; + if ($this->widgetConfiguration['nodes'] instanceof ArrayIterator) { + $this->nodes = $this->widgetConfiguration['nodes']->getArrayCopy(); + } else { + $this->nodes = $this->widgetConfiguration['nodes']; + } $this->nodeTypeFilter = $this->widgetConfiguration['nodeTypeFilter'] ?: null; $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], true); $this->maximumNumberOfNodes = $this->configuration['maximumNumberOfNodes'];