r79980 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79979‎ | r79980 | r79981 >
Date:00:06, 11 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Check against the stored tms instead of the initial var
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.hooks.php (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.hooks.php
@@ -30,7 +30,8 @@
3131
3232 $currentLang = LiveTranslateFunctions::getCurrentLang( $title );
3333
34 - if ( $title->getFullText() == $egLiveTranslateDirPage ) {
 34+ // FIXME: Hitting the db on every page load should be avoided
 35+ if ( in_array( $title->getFullText(), LiveTranslateFunctions::getLTFMemoryNames() ) ) {
3536 LiveTranslateFunctions::createInitialMemoryIfNeeded();
3637
3738 $parser = new LTLTFParser();
@@ -198,7 +199,8 @@
199200
200201 $title = $article->getTitle();
201202
202 - if ( $title->getFullText() == $egLiveTranslateDirPage ) {
 203+ // FIXME: Hitting the db on every page save should be avoided
 204+ if ( in_array( $title->getFullText(), LiveTranslateFunctions::getLTFMemoryNames() ) ) {
203205 $requestData = array(
204206 'action' => 'importtms',
205207 'format' => 'json',
Index: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php
@@ -346,4 +346,31 @@
347347 }
348348 }
349349
 350+ /**
 351+ * Returns the pages containing live translate format dictionaries.
 352+ *
 353+ * @since 0.4
 354+ *
 355+ * @return array
 356+ */
 357+ public static function getLTFMemoryNames() {
 358+ $dbr = wfGetDb( DB_MASTER );
 359+
 360+ $res = $dbr->select(
 361+ 'live_translate_memories',
 362+ array( 'memory_location' ),
 363+ array( 'memory_type' => 0 ),
 364+ __METHOD__,
 365+ array( 'LIMIT' => '5000' )
 366+ );
 367+
 368+ $names = array();
 369+
 370+ foreach ( $res as $tm ) {
 371+ $names[] = $tm->memory_location;
 372+ }
 373+
 374+ return $names;
 375+ }
 376+
350377 }
\ No newline at end of file

Status & tagging log