r35987 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35986‎ | r35987 | r35988 >
Date:08:49, 7 June 2008
Author:rotem
Status:old
Tags:
Comment:
The current implementation slows down maintenance/language/checkExtensions.php, especially in heavy extensions such as CentralAuth, as it seems to parse the language file again for every single message; fixing it to cache the messages.
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageGroups.php
@@ -64,6 +64,11 @@
6565 public function getMangler() { return $this->mangler; }
6666 public function setMangler( $value ) { $this->mangler = $value; }
6767
 68+ /**
 69+ * All the messages for this group, by language code.
 70+ */
 71+ private $messages = array();
 72+
6873 public static function factory( $label, $id ) {
6974 return null;
7075 }
@@ -106,8 +111,10 @@
107112 * @return Stored translation or null.
108113 */
109114 public function getMessage( $key, $code ) {
110 - $cache = $this->load( $code );
111 - return isset( $cache[$key] ) ? $cache[$key] : null;
 115+ if( !isset( $this->messages[$code] ) ) {
 116+ $this->messages[$code] = $this->load( $code );
 117+ }
 118+ return isset( $this->messages[$code][$key] ) ? $this->messages[$code][$key] : null;
112119 }
113120
114121 /**

Status & tagging log