(bug 11562) API: Added a user_registration parameter/field to the list=allusers query...
[lhc/web/wiklou.git] / includes / Pager.php
index 7d8327a..70d0873 100644 (file)
@@ -107,6 +107,9 @@ abstract class IndexPager implements Pager {
                $this->mResult = $this->reallyDoQuery( $this->mOffset, $queryLimit, $descending );
                $this->extractResultInfo( $this->mOffset, $queryLimit, $this->mResult );
                $this->mQueryDone = true;
+               
+               $this->preprocessResults( $this->mResult );
+               $this->mResult->rewind(); // Paranoia
 
                wfProfileOut( $fname );
        }
@@ -170,14 +173,14 @@ abstract class IndexPager implements Pager {
         * @param boolean $descending Query direction, false for ascending, true for descending
         * @return ResultWrapper
         */
-       function reallyDoQuery( $offset, $limit, $ascending ) {
+       function reallyDoQuery( $offset, $limit, $descending ) {
                $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
                $info = $this->getQueryInfo();
                $tables = $info['tables'];
                $fields = $info['fields'];
                $conds = isset( $info['conds'] ) ? $info['conds'] : array();
                $options = isset( $info['options'] ) ? $info['options'] : array();
-               if ( $ascending ) {
+               if ( $descending ) {
                        $options['ORDER BY'] = $this->mIndexField;
                        $operator = '>';
                } else {
@@ -192,6 +195,13 @@ abstract class IndexPager implements Pager {
                return new ResultWrapper( $this->mDb, $res );
        }
 
+       /**
+        * Pre-process results; useful for performing batch existence checks, etc.
+        *
+        * @param ResultWrapper $result Result wrapper
+        */
+       protected function preprocessResults( $result ) {}
+
        /**
         * Get the formatted result list. Calls getStartBody(), formatRow() and 
         * getEndBody(), concatenates the results and returns them.
@@ -702,4 +712,4 @@ abstract class TablePager extends IndexPager {
         */
        abstract function getFieldNames();
 }
-?>
+