[BUGFIX] Possible division by zero in PaginateController 22/46322/2
authorXavier Perseguers <xavier@typo3.org>
Tue, 26 Jan 2016 08:48:15 +0000 (09:48 +0100)
committerXavier Perseguers <xavier@typo3.org>
Fri, 29 Jan 2016 08:53:55 +0000 (09:53 +0100)
Change-Id: Iefec45baa5492b516bc041a08cdd322687fff297
Releases: master, 7.6
Resolves: #72940
Reviewed-on: https://review.typo3.org/46235
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Eric Chavaillaz <eric@hemmer.ch>
Tested-by: Eric Chavaillaz <eric@hemmer.ch>
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
Reviewed-on: https://review.typo3.org/46322

typo3/sysext/fluid/Classes/ViewHelpers/Be/Widget/Controller/PaginateController.php
typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php

index e101e39..d927bdc 100644 (file)
@@ -63,7 +63,8 @@ class PaginateController extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetCont
         $this->objects = $this->widgetConfiguration['objects'];
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $this->widgetConfiguration['configuration'], false);
         $this->numberOfObjects = count($this->objects);
-        $this->numberOfPages = ceil($this->numberOfObjects / (int)$this->configuration['itemsPerPage']);
+        $itemsPerPage = (int)$this->configuration['itemsPerPage'];
+        $this->numberOfPages = $itemsPerPage > 0 ? ceil($this->numberOfObjects / $itemsPerPage) : 0;
     }
 
     /**
index 8b72fa6..949548a 100644 (file)
@@ -79,7 +79,8 @@ class PaginateController extends AbstractWidgetController
     {
         $this->objects = $this->widgetConfiguration['objects'];
         ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $this->widgetConfiguration['configuration'], false);
-        $this->numberOfPages = ceil(count($this->objects) / (int)$this->configuration['itemsPerPage']);
+        $itemsPerPage = (int)$this->configuration['itemsPerPage'];
+        $this->numberOfPages = $itemsPerPage > 0 ? ceil(count($this->objects) / $itemsPerPage) : 0;
         $this->maximumNumberOfLinks = (int)$this->configuration['maximumNumberOfLinks'];
     }