r37701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37700‎ | r37701 | r37702 >
Date:16:11, 15 July 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Fix warnings and little speed improvement
Modified paths:
  • /trunk/extensions/Translate/Message.php (modified) (history)
  • /trunk/extensions/Translate/groups/MediaWikiExtensions.php (modified) (history)
  • /trunk/extensions/Translate/scripts/createCheckIndex.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/groups/MediaWikiExtensions.php
@@ -212,7 +212,7 @@
213213
214214 function getBools() {
215215 $this->init();
216 - $bools = array();
 216+ $bools = parent::getBools();
217217 foreach ( $this->classes as $class ) {
218218 $newbools = ( $class->getBools() );
219219 if ( count($newbools['optional']) || count($newbools['ignored']) ) {
Index: trunk/extensions/Translate/scripts/createCheckIndex.php
@@ -51,15 +51,19 @@
5252 continue;
5353 }
5454
 55+ // Initialise messages, using unique definitions if appropriate
 56+ $collection_skel = $g->initCollection( 'en', $g->isMeta() );
 57+ if ( !count($collection_skel) ) continue;
 58+
5559 STDOUT( "Working with $id: ", $id );
5660
5761 foreach ( $codes as $code ) {
5862 STDOUT( "$code ", $id );
5963
60 - // Initialise messages, using unique definitions if appropriate
61 - $collection = $g->initCollection( $code, $g->isMeta() );
 64+ $collection = clone $collection_skel;
 65+ $collection->code = $code;
 66+
6267 $g->fillCollection( $collection );
63 - $namespace = $g->namespaces[0];
6468
6569 foreach ( $collection->keys() as $key ) {
6670 $prob = $checker->doFastChecks( $collection[$key], $type, $code );
@@ -67,7 +71,7 @@
6872
6973 if ( $verbose ) {
7074 // Print it
71 - $nsText = $wgContLang->getNsText( $namespace );
 75+ $nsText = $wgContLang->getNsText( $g->namespaces[0] );
7276 STDOUT( "# [[$nsText:$key/$code]]" );
7377 }
7478
Index: trunk/extensions/Translate/Message.php
@@ -17,6 +17,10 @@
1818 * translation target language.
1919 */
2020 class MessageCollection implements Iterator, ArrayAccess, Countable {
 21+ /**
 22+ * Information of what type of MessageCollection this is.
 23+ */
 24+ public $code = null;
2125
2226 /**
2327 * Messages are stored in an array.
@@ -24,11 +28,6 @@
2529 private $messages = array();
2630
2731 /**
28 - * Information of what type of MessageCollection this is.
29 - */
30 - public $code = null;
31 -
32 - /**
3332 * Creates new empty messages collection.
3433 *
3534 * @param $code Language code
@@ -37,6 +36,12 @@
3837 $this->code = $code;
3938 }
4039
 40+ public function __clone() {
 41+ foreach ( $this->messages as $key => $obj ) {
 42+ $this->messages[$key] = clone $obj;
 43+ }
 44+ }
 45+
4146 /* Iterator methods */
4247 public function rewind() {
4348 reset($this->messages);

Status & tagging log