r56788 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56787‎ | r56788 | r56789 >
Date:21:27, 22 September 2009
Author:brion
Status:ok
Tags:
Comment:
Merge r56784 updates for multi-db access
Modified paths:
  • /branches/wmf-deployment/extensions/LocalisationUpdate (modified) (history)
  • /branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)
  • /branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.i18n.php (modified) (history)
  • /branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.i18n.php
@@ -86,6 +86,13 @@
8787 'localisationupdate-desc' => 'Źaržy lokalizěrowane powěźeńki tak aktualne ako móžno',
8888 );
8989
 90+/** Greek (Ελληνικά)
 91+ * @author Omnipaedista
 92+ */
 93+$messages['el'] = array(
 94+ 'localisationupdate-desc' => 'Διατηρεί τις μεταφράσεις μηνυμάτων όσο πιο ενημερωμένες γίνεται',
 95+);
 96+
9097 /** Spanish (Español)
9198 * @author Crazymadlover
9299 */
@@ -296,6 +303,13 @@
297304 'localisationupdate-desc' => 'Udržiava lokalizované správy čo najaktuálnejšie',
298305 );
299306
 307+/** Veps (Vepsan kel')
 308+ * @author Игорь Бродский
 309+ */
 310+$messages['vep'] = array(
 311+ 'localisationupdate-desc' => 'Pidab lokaliziruidud tedotused veresin, ku voib',
 312+);
 313+
300314 /** Vietnamese (Tiếng Việt)
301315 * @author Vinhtantran
302316 */
Index: branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.php
@@ -21,6 +21,18 @@
2222
2323 $wgLocalisationUpdateRetryAttempts = 5;
2424
 25+/**
 26+ * If you want to share LocalisationUpdate info between multiple wikis,
 27+ * you can have them reference a central copy of the tables in a given
 28+ * database. Must be accessible via the main database connection.
 29+ *
 30+ * Note that if your wikis have different extensions enabled, you may
 31+ * wish to pass the --all option to LocalisationUpdate/update.php so it
 32+ * pulls updates for all extensions present in the source tree instead
 33+ * of just the ones you have enabled on the wiki you run it from.
 34+ */
 35+$wgLocalisationUpdateDatabase = false;
 36+
2537 // Info about me!
2638 $wgExtensionCredits['other'][] = array(
2739 'path' => __FILE__,
Index: branches/wmf-deployment/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -20,7 +20,7 @@
2121
2222 // Get the message from the database
2323 $conds = array( 'lo_key' => $lckey, 'lo_language' => $langcode );
24 - $result = $db->selectField( 'localisation', 'lo_value', $conds, __METHOD__ ); // Check if the database has any updated message
 24+ $result = $db->selectField( self::table( 'localisation' ), 'lo_value', $conds, __METHOD__ ); // Check if the database has any updated message
2525 if ( $result === false ) { // If no results found, exit here
2626 return true;
2727 }
@@ -35,7 +35,7 @@
3636 $dbr = wfGetDB ( DB_SLAVE );
3737
3838 // Get the messages from the database
39 - $res = $dbr->select( 'localisation',
 39+ $res = $dbr->select( self::table( 'localisation' ),
4040 array( 'lo_key', 'lo_value' ),
4141 array( 'lo_language' => $langcode ),
4242 __METHOD__ );
@@ -279,7 +279,7 @@
280280 // Add the messages we got with our previous update(s) to the local array (as we already got these as well)
281281 $fields = array( 'lo_key', 'lo_value' );
282282 $conds = array( 'lo_language' => $langcode );
283 - $result = $db->select( 'localisation', $fields, $conds, __METHOD__ );
 283+ $result = $db->select( self::table( 'localisation' ), $fields, $conds, __METHOD__ );
284284 foreach ( $result as $r ) {
285285 $compare_messages[$r->lo_key] = $r->lo_value;
286286 }
@@ -316,7 +316,7 @@
317317 $db = wfGetDB( DB_MASTER );
318318
319319 $hashConds = array( 'lfh_file' => $file, 'lfh_hash' => $hash );
320 - $result = $db->select( 'localisation_file_hash', '*', $hashConds, __METHOD__ );
 320+ $result = $db->select( self::table( 'localisation_file_hash' ), '*', $hashConds, __METHOD__ );
321321 if ( $db->numRows( $result ) == 0 ) {
322322 return true;
323323 } else {
@@ -329,7 +329,7 @@
330330 // Double query sucks but we wanna make sure we don't update
331331 // the timestamp when the hash hasn't changed
332332 if ( self::checkHash( $file, $hash ) )
333 - $db->replace( 'localisation_file_hash', array( 'lfh_file' ), array(
 333+ $db->replace( self::table( 'localisation_file_hash' ), array( 'lfh_file' ), array(
334334 'lfh_file' => $file,
335335 'lfh_hash' => $hash,
336336 'lfh_timestamp' => $db->timestamp( wfTimestamp() )
@@ -358,7 +358,7 @@
359359 'lo_language' => $langcode,
360360 'lo_key' => $key
361361 );
362 - $db->replace( 'localisation',
 362+ $db->replace( self::table( 'localisation' ),
363363 array( 'PRIMARY' ), $values,
364364 __METHOD__ );
365365
@@ -479,7 +479,7 @@
480480 // Add the already known messages to the array so we will only find new changes
481481 $fields = array( 'lo_key', 'lo_value' );
482482 $conds = array( 'lo_language' => $language );
483 - $result = $db->select( 'localisation', $fields, $conds, __METHOD__ );
 483+ $result = $db->select( self::table( 'localisation' ), $fields, $conds, __METHOD__ );
484484 foreach ( $result as $r ) {
485485 $compare_messages[$r->lo_key] = $r->lo_value;
486486 }
@@ -544,6 +544,15 @@
545545 return false;
546546 }
547547 }
 548+
 549+ public static function table( $table ) {
 550+ global $wgLocalisationUpdateDatabase;
 551+ if( $wgLocalisationUpdateDatabase ) {
 552+ return "$wgLocalisationUpdateDatabase.$table";
 553+ } else {
 554+ return $table;
 555+ }
 556+ }
548557 }
549558
550559 class LUDependency extends CacheDependency {
@@ -561,7 +570,9 @@
562571 function getTimestamp() {
563572 $dbr = wfGetDB( DB_SLAVE );
564573 return $dbr->selectField(
565 - 'localisation_file_hash', 'MAX(lfh_timestamp)', '',
 574+ LocalisationUpdate::table( 'localisation_file_hash' ),
 575+ 'MAX(lfh_timestamp)',
 576+ '',
566577 __METHOD__ );
567578 }
568579
Property changes on: branches/wmf-deployment/extensions/LocalisationUpdate
___________________________________________________________________
Name: svn:mergeinfo
569580 - /trunk/extensions/LocalisationUpdate:56207,56209,56296,56333,56355
/trunk/phase3/extensions/LocalisationUpdate:55198,56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350
570581 + /trunk/extensions/LocalisationUpdate:56151-56784
/trunk/phase3/extensions/LocalisationUpdate:55198,56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56784Add $wgLocalisationUpdateDatabase config var to pull from a central database....brion20:13, 22 September 2009

Status & tagging log