Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r14865 -r14892 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14865) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14892) @@ -1,6 +1,6 @@ SelectClause); $q = !$for_counting ? $this->addCalculatedFields($q, 0) : str_replace('%2$s', '', $q); @@ -697,7 +698,7 @@ $group = $this->GetGroupClause(); if ( $for_counting ) { - $optimizer = new LeftJoinOptimizer($q, $where . '|' . $having . '|' . $order . '|' . $group); + $optimizer = new LeftJoinOptimizer($q, $where . '|' . $having . '|' . $order . '|' . $group . '|' . $keep_clause); $q = $optimizer->simplify(); } @@ -1171,17 +1172,26 @@ } /** - * Returns total page count based on list per-page - * - * @param string - * @access public - */ + * Returns total page count based on list per-page + * + * @return int + * @access public + */ public function GetTotalPages() { - if (!$this->Counted) $this->CountRecs(); - if ($this->PerPage == -1) return 1; - $this->TotalPages = (($this->RecordsCount - ($this->RecordsCount % $this->PerPage)) / $this->PerPage) // integer part of division - + (($this->RecordsCount % $this->PerPage) != 0); // adds 1 if there is a reminder + if ( !$this->Counted ) { + $this->CountRecs(); + } + + if ( $this->PerPage == -1 ) { + return 1; + } + + $integer_part = ($this->RecordsCount - ($this->RecordsCount % $this->PerPage)) / $this->PerPage; + $reminder = ($this->RecordsCount % $this->PerPage) != 0; // adds 1 if there is a reminder + + $this->TotalPages = $integer_part + $reminder; + return $this->TotalPages; }