From 99ee7b7cf65820ebefefc06a2da0d5770ecd2f40 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sat, 25 Jun 2011 07:21:29 +0000 Subject: [PATCH] Let $wgCategoryCollation take a class name as a value so that extensions 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 | 2 ++ includes/Collation.php | 13 ++++++++++++- includes/DefaultSettings.php | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index a1ce16f15d..b173472d1c 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/Collation.php b/includes/Collation.php index 4cd921d95c..e6c98f1f5c 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -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\"" ); + } } } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 158bb5940e..723ef4e8e7 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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'; -- 2.20.1