r51181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51180‎ | r51181 | r51182 >
Date:08:20, 30 May 2009
Author:thedevilonline
Status:deferred
Tags:
Comment:
- Fixed a bug with duplicate keys!
Modified paths:
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -307,10 +307,11 @@
308308 // If this message wasn't changed in english
309309 if ( !array_key_exists( $key , $forbiddenKeys ) ) {
310310 // See if we can update the database
 311+
311312 $values = array( 'lo_value' => $base_messages[$key] );
312313 $conds = array( 'lo_language' => $langcode, 'lo_key' => $key );
313 - $db->update( 'localisation', $values, $conds, __METHOD__ );
314 - if ( $db->affectedRows() == 0 ) { // Otherwise do a new insert
 314+ $result = $db->select( 'localisation', 'lo_value', $conds, __METHOD__ );
 315+ if($db->numRows($result) == 0) {
315316 $inserts = array(
316317 'lo_value' => $base_messages[$key],
317318 'lo_language' => $langcode,
@@ -320,6 +321,11 @@
321322 if ( $db->affectedRows() == 0 ) {
322323 throw new MWException( "An error has occured while inserting a new message into the database!" );
323324 }
 325+ } else {
 326+ $db->update( 'localisation', $values, $conds, __METHOD__ );
 327+ if ( $db->affectedRows() == 0 ) {
 328+ throw new MWException( "An error has occured while updateing a message in the database!" );
 329+ }
324330 }
325331
326332 // Output extra logmessages when needed

Status & tagging log