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());
}