r50428 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50427‎ | r50428 | r50429 >
Date:10:47, 10 May 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* Bugfixes
Modified paths:
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -262,12 +262,12 @@
263263 return $db->select( 'revtag', $fields, $conds, __METHOD__, $options );
264264 }
265265
266 - public function getTranslationPercentages() {
 266+ public function getTranslationPercentages( $force = false ) {
267267 // Check the memory cache, as this is very slow to calculate
268268 global $wgMemc;
269269 $memcKey = wfMemcKey( 'pt', 'status', $this->getTitle()->getPrefixedText() );
270270 $cache = $wgMemc->get( $memcKey );
271 - if ( is_array( $cache ) ) return $cache;
 271+ if ( !$force && is_array( $cache ) ) return $cache;
272272
273273 // Fetch the available translation pages from database
274274 $dbr = wfGetDB( DB_SLAVE );
@@ -303,7 +303,6 @@
304304 // English is always up-to-date
305305 $temp['en'] = 1.00;
306306
307 - // TODO: Ideally there would be some kind of purging here
308307 $wgMemc->set( $memcKey, $temp, 60*60*12 );
309308 return $temp;
310309 }
@@ -376,10 +375,11 @@
377376
378377 public static function isTranslationPage( Title $title ) {
379378 if ( $title->getText() === $title->getBaseText() ) return false;
380 -
381 - $page = TranslatablePage::newFromTitle(
382 - self::changeTitleText( $title, $title->getBaseText() ) );
383379
 380+ $newtitle = self::changeTitleText( $title, $title->getBaseText() );
 381+ if ( !$newtitle ) throw new MWException( $title->getPrefixedText() );
 382+ $page = TranslatablePage::newFromTitle( $newtitle );
 383+
384384 if ( $page->getMarkedTag() === false ) return false;
385385 return $page;
386386 }
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -327,7 +327,10 @@
328328
329329 $page->addMarkedTag( $newrevision, $changed );
330330
 331+ // Re-generate caches
331332 MessageIndex::cache( NS_TRANSLATIONS );
 333+ $page->getTranslationPercentages( true );
 334+
332335 return false;
333336 }
334337
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -384,7 +384,7 @@
385385 $pers = $page->getTranslationPercentages();
386386 $per = @$pers[$title->getSubpageText()];
387387 $per = ($per === null) ? 0 : $per * 100;
388 - $titleText = $page->getTitle()->getText();
 388+ $titleText = $page->getTitle()->getPrefixedText();
389389 $url = $page->getTranslationUrl( $title->getSubpageText() );
390390
391391 // Output

Status & tagging log