Index: branches/wmf/1.17wmf1/extensions/LocalisationUpdate/LocalisationUpdate.class.php |
— | — | @@ -277,8 +277,8 @@ |
278 | 278 | $attempts++; |
279 | 279 | } |
280 | 280 | 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; |
283 | 283 | } |
284 | 284 | } else {// otherwise try file_get_contents |
285 | 285 | if ( !( $basefilecontents = file_get_contents( $basefile ) ) ) { |
— | — | @@ -325,7 +325,7 @@ |
326 | 326 | // Check if the file has changed since our last update. |
327 | 327 | if ( !$alwaysGetResult ) { |
328 | 328 | 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 ); |
330 | 330 | return array(); |
331 | 331 | } |
332 | 332 | } |
— | — | @@ -349,7 +349,7 @@ |
350 | 350 | // If this is the remote file check if the file has changed since our last update. |
351 | 351 | if ( preg_match( "/^http/", $comparefile ) && !$alwaysGetResult ) { |
352 | 352 | 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 ); |
354 | 354 | return array(); |
355 | 355 | } |
356 | 356 | } |
— | — | @@ -359,7 +359,7 @@ |
360 | 360 | |
361 | 361 | // If the localfile and the remote file are the same, skip them! |
362 | 362 | 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 ); |
364 | 364 | return array(); |
365 | 365 | } |
366 | 366 | |
— | — | @@ -374,12 +374,12 @@ |
375 | 375 | |
376 | 376 | // If we want to save the differences. |
377 | 377 | if ( $saveResults && !empty( $changedStrings ) && is_array( $changedStrings ) ) { |
378 | | - self::myLog( "--Checking languagecode {$langcode}--" ); |
| 378 | + self::myLog( "--Checking languagecode {$langcode}--", $verbose ); |
379 | 379 | // Save the differences. |
380 | 380 | $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 ); |
382 | 382 | } elseif ( $saveResults ) { |
383 | | - self::myLog( "--{$langcode} hasn't changed--" ); |
| 383 | + self::myLog( "--{$langcode} hasn't changed--", $verbose ); |
384 | 384 | } |
385 | 385 | |
386 | 386 | self::saveHash( $basefile, $basehash ); |
— | — | @@ -447,7 +447,7 @@ |
448 | 448 | // Output extra logmessages when needed. |
449 | 449 | if ( $verbose ) { |
450 | 450 | $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 ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Update the counter. |
— | — | @@ -492,18 +492,18 @@ |
493 | 493 | if ( preg_match( "/^http/", $basefile ) && !$alwaysGetResult ) { |
494 | 494 | // Check if the hash has changed |
495 | 495 | 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 ); |
497 | 497 | return 0; |
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
501 | 501 | // And get the real contents |
502 | 502 | $base_messages = self::parsePHP( $basefilecontents, 'base_messages' ); |
503 | | - |
| 503 | + |
504 | 504 | $comparefilecontents = self::getFileContents( $comparefile ); |
505 | | - |
| 505 | + |
506 | 506 | if ( $comparefilecontents === false || $comparefilecontents === '' ) { |
507 | | - return 0; // Failed |
| 507 | + return 0; // Failed |
508 | 508 | } |
509 | 509 | |
510 | 510 | // Only get what we need. |
— | — | @@ -512,21 +512,21 @@ |
513 | 513 | // Rename the array. |
514 | 514 | $comparefilecontents = preg_replace( "/\\\$messages/", "\$compare_messages", $comparefilecontents ); |
515 | 515 | $comparehash = md5( $comparefilecontents ); |
516 | | - |
| 516 | + |
517 | 517 | if ( preg_match( "/^http/", $comparefile ) && !$alwaysGetResult ) { |
518 | 518 | // Check if the remote file has changed |
519 | 519 | 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 ); |
521 | 521 | return 0; |
522 | 522 | } |
523 | 523 | } |
524 | | - |
| 524 | + |
525 | 525 | // Get the real array. |
526 | 526 | $compare_messages = self::parsePHP( $comparefilecontents, 'compare_messages' ); |
527 | 527 | |
528 | 528 | // If both files are the same, they can be skipped. |
529 | 529 | 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 ); |
531 | 531 | return 0; |
532 | 532 | } |
533 | 533 | |
— | — | @@ -576,17 +576,17 @@ |
577 | 577 | |
578 | 578 | // If we want to save the changes. |
579 | 579 | if ( $saveResults === true && !empty( $changedStrings ) && is_array( $changedStrings ) ) { |
580 | | - self::myLog( "--Checking languagecode {$language}--" ); |
| 580 | + self::myLog( "--Checking languagecode {$language}--", $verbose ); |
581 | 581 | // The save them |
582 | 582 | $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 ); |
584 | 584 | } elseif($saveResults === true) { |
585 | | - self::myLog( "--{$language} hasn't changed--" ); |
| 585 | + self::myLog( "--{$language} hasn't changed--", $verbose ); |
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | // 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 ); |
591 | 591 | |
592 | 592 | self::saveHash( $basefile, $basehash ); |
593 | 593 | |
— | — | @@ -600,7 +600,10 @@ |
601 | 601 | * |
602 | 602 | * @param $log String |
603 | 603 | */ |
604 | | - public static function myLog( $log ) { |
| 604 | + public static function myLog( $log, $verbose = true ) { |
| 605 | + if ( !$verbose ) { |
| 606 | + return; |
| 607 | + } |
605 | 608 | if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) { |
606 | 609 | wfDebug( $log . "\n" ); |
607 | 610 | } else { |
Property changes on: branches/wmf/1.17wmf1/extensions/LocalisationUpdate |
___________________________________________________________________ |
Modified: svn:mergeinfo |
608 | 611 | Merged /trunk/extensions/LocalisationUpdate:r86299 |