r55275 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55274‎ | r55275 | r55276 >
Date:21:33, 18 August 2009
Author:catrope
Status:deferred
Tags:
Comment:
LocalisationUpdate: Make LU compatible with 1.15 and below by re-adding the MessageNotInMwNs hook removed in r54936
Modified paths:
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.php
@@ -33,6 +33,7 @@
3434 );
3535
3636 // Use the right hook
 37+$wgHooks['MessageNotInMwNs'][] = 'LocalisationUpdate::FindUpdatedMessages'; // MW <= 1.15
3738 $wgHooks['LocalisationCacheRecache'][] = 'LocalisationUpdate::onRecache'; // MW 1.16+
3839
3940 $dir = dirname( __FILE__ ) . '/';
Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -1,6 +1,34 @@
22 <?php
33 class LocalisationUpdate {
44 // DB Search funtion
 5+ // MW <= 1.15
 6+ public static function FindUpdatedMessage( &$message, $lckey, $langcode, $isFullKey ) {
 7+ // Define a cache
 8+ static $cache = array();
 9+ $db = wfGetDB ( DB_SLAVE );
 10+
 11+ // If the key also contains the language code remove the language code from the key
 12+ if ( $isFullKey ) {
 13+ $lckey = preg_replace( "/\/" . $langcode . "/", "", $lckey );
 14+ }
 15+
 16+ // If message is in the cache, don't get an update!
 17+ if ( array_key_exists( $lckey . "/" . $langcode, $cache ) ) {
 18+ $message = $cache[$lckey . "/" . $langcode];
 19+
 20+ // Get the message from the database
 21+ $conds = array( 'lo_key' => $lckey, 'lo_language' => $langcode );
 22+ $result = $db->selectField( 'localisation', 'lo_value', $conds, __METHOD__ ); // Check if the database has any updated message
 23+ if ( $result === false ) { // If no results found, exit here
 24+ return true;
 25+ }
 26+
 27+ $message = $result;
 28+ $cache[$lckey . "/" . $langcode] = $result; // Update the cache
 29+ return true;
 30+ }
 31+
 32+ // MW 1.16+
533 public static function onRecache( $lc, $langcode, &$cache ) {
634 $dbr = wfGetDB ( DB_SLAVE );
735

Follow-up revisions

RevisionCommit summaryAuthorDate
r55276Fix fatals in r55275catrope21:42, 18 August 2009
r55283wmf-deployment: Merge r55275 and r55276: fixes for LocalisationUpdatecatrope22:22, 18 August 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54936Simplistic reorganisation for compatibility with r52503. Load messages pre-ca...tstarling14:16, 13 August 2009

Status & tagging log