r86300 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86299‎ | r86300 | r86301 >
Date:10:53, 18 April 2011
Author:reedy
Status:ok
Tags:
Comment:
MFT r86299
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/LocalisationUpdate (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -277,8 +277,8 @@
278278 $attempts++;
279279 }
280280 if ( !$basefilecontents ) {
281 - self::myLog( 'Cannot get the contents of ' . $basefile . ' (curl)' );
282 - return false;
 281+ self::myLog( 'Cannot get the contents of ' . $basefile . ' (curl)' );
 282+ return false;
283283 }
284284 } else {// otherwise try file_get_contents
285285 if ( !( $basefilecontents = file_get_contents( $basefile ) ) ) {
@@ -325,7 +325,7 @@
326326 // Check if the file has changed since our last update.
327327 if ( !$alwaysGetResult ) {
328328 if ( !self::checkHash( $basefile, $basehash ) ) {
329 - self::myLog( "Skipping {$langcode} since the remote file hasn't changed since our last update" );
 329+ self::myLog( "Skipping {$langcode} since the remote file hasn't changed since our last update", $verbose );
330330 return array();
331331 }
332332 }
@@ -349,7 +349,7 @@
350350 // If this is the remote file check if the file has changed since our last update.
351351 if ( preg_match( "/^http/", $comparefile ) && !$alwaysGetResult ) {
352352 if ( !self::checkHash( $comparefile, $comparehash ) ) {
353 - self::myLog( "Skipping {$langcode} since the remote file has not changed since our last update" );
 353+ self::myLog( "Skipping {$langcode} since the remote file has not changed since our last update", $verbose );
354354 return array();
355355 }
356356 }
@@ -359,7 +359,7 @@
360360
361361 // If the localfile and the remote file are the same, skip them!
362362 if ( $basehash == $comparehash && !$alwaysGetResult ) {
363 - self::myLog( "Skipping {$langcode} since the remote file is the same as the local file" );
 363+ self::myLog( "Skipping {$langcode} since the remote file is the same as the local file", $verbose );
364364 return array();
365365 }
366366
@@ -374,12 +374,12 @@
375375
376376 // If we want to save the differences.
377377 if ( $saveResults && !empty( $changedStrings ) && is_array( $changedStrings ) ) {
378 - self::myLog( "--Checking languagecode {$langcode}--" );
 378+ self::myLog( "--Checking languagecode {$langcode}--", $verbose );
379379 // Save the differences.
380380 $updates = self::saveChanges( $changedStrings, $forbiddenKeys, $compare_messages, $base_messages, $langcode, $verbose );
381 - self::myLog( "{$updates} messages updated for {$langcode}." );
 381+ self::myLog( "{$updates} messages updated for {$langcode}.", $verbose );
382382 } elseif ( $saveResults ) {
383 - self::myLog( "--{$langcode} hasn't changed--" );
 383+ self::myLog( "--{$langcode} hasn't changed--", $verbose );
384384 }
385385
386386 self::saveHash( $basefile, $basehash );
@@ -447,7 +447,7 @@
448448 // Output extra logmessages when needed.
449449 if ( $verbose ) {
450450 $oldmsg = isset( $compare_messages[$key] ) ? "'{$compare_messages[$key]}'" : 'not set';
451 - self::myLog( "Updated message {$key} from $oldmsg to '{$base_messages[$key]}'" );
 451+ self::myLog( "Updated message {$key} from $oldmsg to '{$base_messages[$key]}'", $verbose );
452452 }
453453
454454 // Update the counter.
@@ -492,18 +492,18 @@
493493 if ( preg_match( "/^http/", $basefile ) && !$alwaysGetResult ) {
494494 // Check if the hash has changed
495495 if ( !self::checkHash( $basefile, $basehash ) ) {
496 - self::myLog( "Skipping {$extension} since the remote file has not changed since our last update" );
 496+ self::myLog( "Skipping {$extension} since the remote file has not changed since our last update", $verbose );
497497 return 0;
498498 }
499499 }
500500
501501 // And get the real contents
502502 $base_messages = self::parsePHP( $basefilecontents, 'base_messages' );
503 -
 503+
504504 $comparefilecontents = self::getFileContents( $comparefile );
505 -
 505+
506506 if ( $comparefilecontents === false || $comparefilecontents === '' ) {
507 - return 0; // Failed
 507+ return 0; // Failed
508508 }
509509
510510 // Only get what we need.
@@ -512,21 +512,21 @@
513513 // Rename the array.
514514 $comparefilecontents = preg_replace( "/\\\$messages/", "\$compare_messages", $comparefilecontents );
515515 $comparehash = md5( $comparefilecontents );
516 -
 516+
517517 if ( preg_match( "/^http/", $comparefile ) && !$alwaysGetResult ) {
518518 // Check if the remote file has changed
519519 if ( !self::checkHash( $comparefile, $comparehash ) ) {
520 - self::myLog( "Skipping {$extension} since the remote file has not changed since our last update" );
 520+ self::myLog( "Skipping {$extension} since the remote file has not changed since our last update", $verbose );
521521 return 0;
522522 }
523523 }
524 -
 524+
525525 // Get the real array.
526526 $compare_messages = self::parsePHP( $comparefilecontents, 'compare_messages' );
527527
528528 // If both files are the same, they can be skipped.
529529 if ( $basehash == $comparehash && !$alwaysGetResult ) {
530 - self::myLog( "Skipping {$extension} since the remote file is the same as the local file" );
 530+ self::myLog( "Skipping {$extension} since the remote file is the same as the local file", $verbose );
531531 return 0;
532532 }
533533
@@ -576,17 +576,17 @@
577577
578578 // If we want to save the changes.
579579 if ( $saveResults === true && !empty( $changedStrings ) && is_array( $changedStrings ) ) {
580 - self::myLog( "--Checking languagecode {$language}--" );
 580+ self::myLog( "--Checking languagecode {$language}--", $verbose );
581581 // The save them
582582 $updates = self::saveChanges( $changedStrings, $forbiddenKeys, $compare_messages[$language], $messages, $language, $verbose );
583 - self::myLog( "{$updates} messages updated for {$language}." );
 583+ self::myLog( "{$updates} messages updated for {$language}.", $verbose );
584584 } elseif($saveResults === true) {
585 - self::myLog( "--{$language} hasn't changed--" );
 585+ self::myLog( "--{$language} hasn't changed--", $verbose );
586586 }
587587 }
588588
589589 // And log some stuff.
590 - self::myLog( "Updated " . $updates . " messages for the '{$extension}' extension" );
 590+ self::myLog( "Updated " . $updates . " messages for the '{$extension}' extension", $verbose );
591591
592592 self::saveHash( $basefile, $basehash );
593593
@@ -600,7 +600,10 @@
601601 *
602602 * @param $log String
603603 */
604 - public static function myLog( $log ) {
 604+ public static function myLog( $log, $verbose = true ) {
 605+ if ( !$verbose ) {
 606+ return;
 607+ }
605608 if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
606609 wfDebug( $log . "\n" );
607610 } else {
Property changes on: branches/wmf/1.17wmf1/extensions/LocalisationUpdate
___________________________________________________________________
Modified: svn:mergeinfo
608611 Merged /trunk/extensions/LocalisationUpdate:r86299

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86299Make logging actually have some variance on $verbosereedy10:44, 18 April 2011

Status & tagging log