X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FPager.php;h=077430d27d3d00fdb828355d2f1671a8a32b43a9;hb=c2b3c1cf671d360910b6234da481c230bbe2a730;hp=be43eda68bfc1249d5a9619043087e2cd58f40fc;hpb=af786d978a5d19678c1b5525cb2a63c8b6a8c9b1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Pager.php b/includes/Pager.php index be43eda68b..077430d27d 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -144,7 +144,10 @@ abstract class IndexPager extends ContextSource implements Pager { # Use consistent behavior for the limit options $this->mDefaultLimit = intval( $this->getUser()->getOption( 'rclimit' ) ); - list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset(); + if ( !$this->mLimit ) { + // Don't override if a subclass calls $this->setLimit() in its constructor. + list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset(); + } $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' ); $this->mDb = wfGetDB( DB_SLAVE ); @@ -236,10 +239,19 @@ abstract class IndexPager extends ContextSource implements Pager { /** * Set the limit from an other source than the request * + * Verifies limit is between 1 and 5000 + * * @param $limit Int|String */ function setLimit( $limit ) { - $this->mLimit = $limit; + $limit = (int) $limit; + // WebRequest::getLimitOffset() puts a cap of 5000, so do same here. + if ( $limit > 5000 ) { + $limit = 5000; + } + if ( $limit > 0 ) { + $this->mLimit = $limit; + } } /** @@ -275,8 +287,7 @@ abstract class IndexPager extends ContextSource implements Pager { if ( $numRows > $this->mLimit && $numRows > 1 ) { $res->seek( $numRows - 1 ); $this->mPastTheEndRow = $res->fetchObject(); - $indexField = $this->mIndexField; - $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexField; + $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexColumn; $res->seek( $numRows - 2 ); $row = $res->fetchRow(); $lastIndex = $row[$indexColumn]; @@ -915,7 +926,7 @@ abstract class TablePager extends IndexPager { $tableClass = htmlspecialchars( $this->getTableClass() ); $sortClass = htmlspecialchars( $this->getSortHeaderClass() ); - $s = "\n"; + $s = "
\n"; $fields = $this->getFieldNames(); # Make table header