r96765 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96764‎ | r96765 | r96766 >
Date:01:13, 11 September 2011
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
(bug 30722) Add an identity collation that sorts things based on what the unicode code point is (aka pre-1.17 behaviour).

I'm tagging this 1.18 because the original bug was for iswiktionary wanting it, so it'd be nice to get it in 1.18.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.18 (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/Collation.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.18
@@ -209,6 +209,7 @@
210210 * Introduced $wgVaryOnXFPForAPI which will cause the API to send
211211 Vary: X-Forwarded-Proto headers.
212212 * New maintenance script to refresh image metadata (maintenance/refreshImageMetadata.php)
 213+* (bug 30722) Add a new collation that sorts categories in ascii sort order.
213214
214215 === Bug fixes in 1.18 ===
215216 * mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php)
Index: trunk/phase3/includes/AutoLoader.php
@@ -118,6 +118,7 @@
119119 'HttpRequest' => 'includes/HttpFunctions.old.php',
120120 'IContextSource' => 'includes/RequestContext.php',
121121 'IcuCollation' => 'includes/Collation.php',
 122+ 'IdentityCollation' => 'includes/Collation.php',
122123 'ImageGallery' => 'includes/ImageGallery.php',
123124 'ImageHistoryList' => 'includes/ImagePage.php',
124125 'ImageHistoryPseudoPager' => 'includes/ImagePage.php',
Index: trunk/phase3/includes/Collation.php
@@ -23,6 +23,8 @@
2424 switch( $collationName ) {
2525 case 'uppercase':
2626 return new UppercaseCollation;
 27+ case 'identity':
 28+ return new IdentityCollation;
2729 case 'uca-default':
2830 return new IcuCollation( 'root' );
2931 default:
@@ -99,6 +101,30 @@
100102 }
101103 }
102104
 105+/**
 106+ * Collation class that's essentially a no-op.
 107+ *
 108+ * Does sorting based on binary value of the string.
 109+ * Like how things were pre 1.17.
 110+ */
 111+class IdentityCollation extends Collation {
 112+
 113+ function getSortKey( $string ) {
 114+ return $string;
 115+ }
 116+
 117+ function getFirstLetter( $string ) {
 118+ global $wgContLang;
 119+ // Copied from UppercaseCollation.
 120+ // I'm kind of unclear on when this could happen...
 121+ if ( $string[0] == "\0" ) {
 122+ $string = substr( $string, 1 );
 123+ }
 124+ return $wgContLang->firstChar( $string );
 125+ }
 126+}
 127+
 128+
103129 class IcuCollation extends Collation {
104130 var $primaryCollator, $mainCollator, $locale;
105131 var $firstLetterData;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4879,6 +4879,8 @@
48804880 *
48814881 * - uppercase: Converts the category name to upper case, and sorts by that.
48824882 *
 4883+ * - identity: Does no conversion. Sorts by binary value of the string.
 4884+ *
48834885 * - uca-default: Provides access to the Unicode Collation Algorithm with
48844886 * the default element table. This is a compromise collation which sorts
48854887 * all languages in a mediocre way. However, it is better than "uppercase".
@@ -4892,7 +4894,7 @@
48934895 * the sort keys in the database.
48944896 *
48954897 * Extensions can define there own collations by subclassing Collation
4896 - * and using the class name as the value of this variable.
 4898+ * and using the Collation::factory hook.
48974899 */
48984900 $wgCategoryCollation = 'uppercase';
48994901

Follow-up revisions

RevisionCommit summaryAuthorDate
r96810(follow-up r96765). Appearently my release notes for that revision were horri...bawolff20:37, 11 September 2011
r976351.18wmf1: MFT r96760, r96765, r97551, r97552, r97622catrope15:54, 20 September 2011
r97673REL1_18 MFT r96760, r76765, r96810, r97551, r97552, r97575, r97607, r97608, r...reedy22:36, 20 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   10:04, 11 September 2011

I'd replace the RELEASE-NOTES bug description with the one in your commit message. The one in release-notes makes no sense :)

#Comment by Catrope (talk | contribs)   11:59, 14 September 2011

Untagging 1.18 and tagging 1.18wmf1. We can deploy this some time after the 1.18 deployment, but it's not a fix for a regression in 1.18.

Status & tagging log