r97071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97070‎ | r97071 | r97072 >
Date:16:48, 14 September 2011
Author:catrope
Status:ok
Tags:
Comment:
Introduce Language::getMessageKeysFor() and use it in ApiQueryAllmessages
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAllmessages.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -65,7 +65,7 @@
6666
6767 // Determine which messages should we print
6868 if ( in_array( '*', $params['messages'] ) ) {
69 - $message_names = array_keys( Language::getMessagesFor( 'en' ) );
 69+ $message_names = Language::getMessageKeysFor( $langObj->getCode() );
7070 sort( $message_names );
7171 $messages_target = $message_names;
7272 } else {
Index: trunk/phase3/includes/specials/SpecialAllmessages.php
@@ -249,6 +249,7 @@
250250 * @param bool $foreign Whether the $langcode is not the content language
251251 */
252252 public static function getCustomisedStatuses( $messageNames, $langcode = 'en', $foreign = false ) {
 253+ // FIXME: This function should be moved to Language:: or something.
253254 wfProfileIn( __METHOD__ . '-db' );
254255
255256 $dbr = wfGetDB( DB_SLAVE );
Index: trunk/phase3/languages/Language.php
@@ -3371,7 +3371,8 @@
33723372
33733373 /**
33743374 * Get all messages for a given language
3375 - * WARNING: this may take a long time
 3375+ * WARNING: this may take a long time. If you just need all message *keys*
 3376+ * but need the *contents* of only a few messages, consider using getMessageKeysFor().
33763377 *
33773378 * @param $code string
33783379 *
@@ -3392,6 +3393,16 @@
33933394 static function getMessageFor( $key, $code ) {
33943395 return self::getLocalisationCache()->getSubitem( $code, 'messages', $key );
33953396 }
 3397+
 3398+ /**
 3399+ * Get all message keys for a given language. This is a faster alternative to
 3400+ * array_keys( Language::getMessagesFor( $code ) )
 3401+ * @param $code string Language code
 3402+ * @return array of message keys (strings)
 3403+ */
 3404+ static function getMessageKeysFor( $code ) {
 3405+ return self::getLocalisationCache()->getSubItemList( $code, 'messages' );
 3406+ }
33963407
33973408 /**
33983409 * @param $talk

Follow-up revisions

RevisionCommit summaryAuthorDate
r97082Merged revisions 97057,97060,97071,97073-97074,97077-97080 via svnmerge from...dantman18:11, 14 September 2011
r97757* follow-up r97636: decrease indentation & mention revision per Nikerabbit...robin19:30, 21 September 2011

Status & tagging log