Let $wgCategoryCollation take a class name as a value so that extensions
authorBrian Wolff <bawolff@users.mediawiki.org>
Sat, 25 Jun 2011 07:21:29 +0000 (07:21 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sat, 25 Jun 2011 07:21:29 +0000 (07:21 +0000)
can define new Collation classes.

(I plan to commit such an extension shortly)

Wasn't sure if it would be better to make an array mapping collation names => class names
instead. However, that seemed to be unneededly complicated so I went with
letting that variable take class names.

RELEASE-NOTES-1.19
includes/Collation.php
includes/DefaultSettings.php

index a1ce16f..b173472 100644 (file)
@@ -27,6 +27,8 @@ production.
   was removed in about 1.5.
 * LogPageValidTypes, LogPageLogName, LogPageLogHeader and LogPageActionText
   hooks have been removed.
+* $wgCategoryCollation can now use a class name as its value, in order for
+  extensions to be able to define new collations
 
 === New features in 1.19 ===
 * BREAKING CHANGE: action=watch / action=unwatch now requires a token.
index 4cd921d..e6c98f1 100644 (file)
@@ -26,7 +26,18 @@ abstract class Collation {
                        case 'uca-default':
                                return new IcuCollation( 'root' );
                        default:
-                               throw new MWException( __METHOD__.": unknown collation type \"$collationName\"" );
+                               # Provide a mechanism for extensions to hook in.
+                               if ( class_exists( $collationName ) ) {
+                                       $collationObject = new $collationName;
+                                       if ( $collationObject instanceof Collation ) {
+                                               return $collationObject;
+                                       } else {
+                                               throw new MWException( __METHOD__.": collation type \"$collationName\""
+                                                       . " is not a subclass of Collation." );
+                                       }
+                               } else {
+                                       throw new MWException( __METHOD__.": unknown collation type \"$collationName\"" );
+                               }
                }
        }
 
index 158bb59..723ef4e 100644 (file)
@@ -4731,6 +4731,9 @@ $wgCategoryPagingLimit = 200;
  *
  * After you change this, you must run maintenance/updateCollation.php to fix
  * the sort keys in the database.
+ *
+ * Extensions can define there own collations by subclassing Collation
+ * and using the class name as the value of this variable.
  */
 $wgCategoryCollation = 'uppercase';