Skip to content

Commit

Permalink
Merge pull request #1067 from ceeram/paginatecount
Browse files Browse the repository at this point in the history
Avoid calling paginateCount when there are no results.
  • Loading branch information
markstory committed Jan 12, 2013
2 parents d571b05 + d3f9cc1 commit e7330fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/Cake/Controller/Component/PaginatorComponent.php
Expand Up @@ -197,7 +197,9 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
$defaults = $this->getDefaults($object->alias);
unset($defaults[0]);

if ($object->hasMethod('paginateCount')) {
if (!$results) {
$count = 0;
} elseif ($object->hasMethod('paginateCount')) {
$count = $object->paginateCount($conditions, $recursive, $extra);
} else {
$parameters = compact('conditions');
Expand Down
Expand Up @@ -140,10 +140,11 @@ class ControllerPaginateModel extends CakeTestModel {
/**
* paginate method
*
* @return void
* @return boolean
*/
public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) {
$this->extra = $extra;
return true;
}

/**
Expand Down

0 comments on commit e7330fa

Please sign in to comment.