makerlabs/PagerBundle

Bad checking for page and limit value

png-tech opened this issue · 1 comments

Division by zero for empty values.

please fix:
A limit and page can not to be zero!!

check it in setLimit and setPage.

To fix:
public function setLimit($limit)
{

  •  $this->limit = max(min($limit > 0 ? $limit : 1, $this->adapter->getTotalResults()),1);
    
  •   $this->limit = min($limit > 0 ? $limit : 1, $this->adapter->getTotalResults()); 
    

    ....

    public function setPage($page)
    {

  •  $this->page = max(min($page > 0 ? $page : $this->getFirstPage(), $this->getLastPage()),1);
    
  •   $this->page = min($page > 0 ? $page : $this->getFirstPage(), $this->getLastPage());
    

fixed