(Follow-up r90759 per CR) Use a hook to register new Collations instead of just takin...
authorBrian Wolff <bawolff@users.mediawiki.org>
Tue, 5 Jul 2011 05:30:04 +0000 (05:30 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Tue, 5 Jul 2011 05:30:04 +0000 (05:30 +0000)
RELEASE-NOTES-1.19
includes/Collation.php

index 2e095df..5802892 100644 (file)
@@ -27,8 +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 hook "Collation::factory" to allow extensions to create custom
+  category collations.
 
 === New features in 1.19 ===
 * BREAKING CHANGE: action=watch / action=unwatch now requires a token.
index e6c98f1..a6f1cfe 100644 (file)
@@ -27,17 +27,16 @@ abstract class Collation {
                                return new IcuCollation( 'root' );
                        default:
                                # 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\"" );
+
+                               $collationObject = null;
+                               wfRunHooks( 'Collation::factory', array( $collationName, &$collationObject ) );
+
+                               if ( $collationObject instanceof Collation ) {
+                                       return $collationObject;
                                }
+
+                               // If all else fails...
+                               throw new MWException( __METHOD__.": unknown collation type \"$collationName\"" );
                }
        }