Trac

Ticket #1021 (closed defect: fixed)

Opened 6 days ago

Last modified 3 days ago

PATCH: sfDoctrinePager causes negative offset

Reported by: nightfreak Assigned to: jwage
Priority: blocker Milestone: 0.11.0
Component: sfDoctrinePlugin Version: 0.11
Keywords: Cc:

Description

Offset must be calculated first. setLastPage may eventually set the current page to 0 and cause a negative offset.

Index: plugins/sfDoctrinePlugin/lib/sfDoctrinePager.class.php =================================================================== --- plugins/sfDoctrinePlugin/lib/sfDoctrinePager.class.php (revision 8815) +++ plugins/sfDoctrinePlugin/lib/sfDoctrinePager.class.php (working copy) @@ -74,10 +74,9 @@

{

$this->setLastPage(0);

} else {

+ $offset = ($this->getPage() - 1) * $this->getMaxPerPage();

$this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));

- $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); -

$p->offset($offset); $p->limit($this->getMaxPerPage());

}

Change History

05/07/08 11:36:51 changed by nightfreak

The error only occures when the result is empty!?

05/10/08 02:52:55 changed by jwage

  • status changed from new to closed.
  • resolution set to fixed.

05/10/08 02:53:09 changed by jwage

  • milestone changed from 0.11.2 to 0.11.0.