r107268 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107267‎ | r107268 | r107269 >
Date:12:19, 25 December 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Followup r107052 - purge the cache too
While at it, fixed a bug in figureMessage, where it would strip the section name from Translations:FooPage/section and not identify message FooPage as valid
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageHandle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageGroups.php
@@ -1110,6 +1110,28 @@
11111111 return isset( $groups[$id] ) ? $groups[$id] : '';
11121112 }
11131113
 1114+ /**
 1115+ * Returns the message groups this message group is part of.
 1116+ * @since 2011-12-15
 1117+ * @return array
 1118+ */
 1119+ public static function getParentGroups( MessageGroup $group ) {
 1120+ // Take the first message, get a handle for it and check
 1121+ // if that message belongs to other groups. Those are the
 1122+ // parent aggregate groups. Ideally we loop over all keys,
 1123+ // but this should be enough.
 1124+ $keys = array_keys( $group->getDefinitions() );
 1125+ $title = Title::makeTitle( $group->getNamespace(), $keys[0] );
 1126+ $handle = new MessageHandle( $title );
 1127+ $ids = $handle->getGroupIds();
 1128+ foreach ( $ids as $index => $id ) {
 1129+ if ( $id === $group->getId() ) {
 1130+ unset( $ids[$index] );
 1131+ }
 1132+ }
 1133+ return $ids;
 1134+ }
 1135+
11141136 /// @todo Make protected.
11151137 public $classes;
11161138 private function __construct() {
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -87,6 +87,11 @@
8888 $dbw->replace( $table, array( $index ), $row, __METHOD__ );
8989 }
9090 $this->listPages();
 91+
 92+ $group = MessageGroups::getGroup( $id );
 93+ $parents = MessageGroups::getParentGroups( $group );
 94+ MessageGroupStats::clearGroup( $parents );
 95+
9196 return;
9297 }
9398
Index: trunk/extensions/Translate/utils/MessageHandle.php
@@ -35,15 +35,20 @@
3636 */
3737 public function figureMessage() {
3838 if ( $this->key === null ) {
39 - $text = $this->getTitle()->getDBkey();
 39+ $title = $this->getTitle();
 40+ // Check if this is a valid message first
 41+ $ns = $title->getNamespace();
 42+ $text = $title->getDBkey();
 43+ $known = TranslateUtils::messageKeyToGroups( $ns, $text );
 44+
4045 $pos = strrpos( $text, '/' );
41 -
42 - if ( $pos === false ) {
 46+ if ( $known || $pos === false ) {
4347 $this->code = '';
4448 $this->key = $text;
4549 } else {
4650 $this->code = substr( $text, $pos + 1 );
4751 $this->key = substr( $text, 0, $pos );
 52+
4853 }
4954 }
5055 return array( $this->key, $this->code );

Follow-up revisions

RevisionCommit summaryAuthorDate
r107271Typo in r107268nikerabbit12:38, 25 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107052I18n #319: don't show discouraged groups in Special:LanguageStatsnikerabbit10:23, 22 December 2011

Comments

#Comment by Siebrand (talk | contribs)   12:23, 25 December 2011

@since is 10 days off

Status & tagging log