From: Alexandre Emsenhuber Date: Wed, 9 May 2012 20:18:58 +0000 (+0200) Subject: (bug 25095) Special:Categories should also include the first relevant item when ... X-Git-Tag: 1.31.0-rc.0~22881^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=1578780002c91e2f1567f099dd89d580adba837e;p=lhc%2Fweb%2Fwiklou.git (bug 25095) Special:Categories should also include the first relevant item when "from" is filled Second attempt after that the first one was reverted in I119160d59c4fca0d069adef60151b30d53b582a1. Change-Id: If301c7cac3fafbcdd6f3ff8e0e822b0db29f09a2 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index ceb552d473..1b1cd97d71 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. diff --git a/includes/Pager.php b/includes/Pager.php index d82f957e81..be43eda68b 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -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 ); diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 6d2831c7b0..1232e3fa75 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -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 ); } }