(bug 25095) Special:Categories should also include the first relevant item when ...
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 9 May 2012 20:18:58 +0000 (22:18 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 2 Aug 2012 08:10:19 +0000 (10:10 +0200)
Second attempt after that the first one was reverted in I119160d59c4fca0d069adef60151b30d53b582a1.

Change-Id: If301c7cac3fafbcdd6f3ff8e0e822b0db29f09a2

RELEASE-NOTES-1.20
includes/Pager.php
includes/specials/SpecialCategories.php

index ceb552d..1b1cd97 100644 (file)
@@ -184,6 +184,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 31644) GlobalUsage, CentralAuth and AbuseLog extensions should not use
   insecure links to foreign wikis in the WikiMap.
 * (bug 36073) Avoid duplicate element IDs on File pages
+* (bug 25095) Special:Categories should also include the first relevant item
+  when "from" is filled.
 
 === API changes in 1.20 ===
 * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
index d82f957..be43eda 100644 (file)
@@ -118,6 +118,11 @@ abstract class IndexPager extends ContextSource implements Pager {
 
        protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar;
 
+       /**
+        * Whether to include the offset in the query
+        */
+       protected $mIncludeOffset = false;
+
        /**
         * Result object for the query. Warning: seek before use.
         *
@@ -237,6 +242,17 @@ abstract class IndexPager extends ContextSource implements Pager {
                $this->mLimit = $limit;
        }
 
+       /**
+        * Set whether a row matching exactly the offset should be also included
+        * in the result or not. By default this is not the case, but when the
+        * offset is user-supplied this might be wanted.
+        *
+        * @param $include bool
+        */
+       public function setIncludeOffset( $include ) {
+               $this->mIncludeOffset = $include;
+       }
+
        /**
         * Extract some useful data from the result object for use by
         * the navigation bar, put it into $this
@@ -337,14 +353,14 @@ abstract class IndexPager extends ContextSource implements Pager {
                $sortColumns = array_merge( array( $this->mIndexField ), $this->mExtraSortFields );
                if ( $descending ) {
                        $options['ORDER BY'] = $sortColumns;
-                       $operator = '>';
+                       $operator = $this->mIncludeOffset ? '>=' : '>';
                } else {
                        $orderBy = array();
                        foreach ( $sortColumns as $col ) {
                                $orderBy[] = $col . ' DESC';
                        }
                        $options['ORDER BY'] = $orderBy;
-                       $operator = '<';
+                       $operator = $this->mIncludeOffset ? '<=' : '<';
                }
                if ( $offset != '' ) {
                        $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
index 6d2831c..1232e3f 100644 (file)
@@ -64,7 +64,8 @@ class CategoryPager extends AlphabeticPager {
                $from = str_replace( ' ', '_', $from );
                if( $from !== '' ) {
                        $from = Title::capitalize( $from, NS_CATEGORY );
-                       $this->mOffset = $from;
+                       $this->setOffset( $from );
+                       $this->setIncludeOffset( true );
                }
        }