r51148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51147‎ | r51148 | r51149 >
Date:08:51, 29 May 2009
Author:thedevilonline
Status:deferred
Tags:
Comment:
- Added the ability to automatically retry to get the contents of a file (after sleeping for 1 second)
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
@@ -21,4 +21,6 @@
2222 $dir = dirname( __FILE__ ) . '/';
2323 $wgExtensionMessagesFiles['LocalisationUpdate'] = $dir . 'LocalisationUpdate.i18n.php';
2424 $wgAutoloadClasses['LocalisationUpdate'] = $dir . 'LocalisationUpdate.class.php';
25 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'LocalisationUpdate::schemaUpdates';
\ No newline at end of file
 25+$wgHooks['LoadExtensionSchemaUpdates'][] = 'LocalisationUpdate::schemaUpdates';
 26+
 27+$wgLocalisationUpdateRetryAttempts = 5;
\ No newline at end of file
Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -44,7 +44,7 @@
4545
4646 // Update all Extension messages
4747 foreach ( $wgExtensionMessagesFiles as $extension => $locFile ) {
48 - $result = self::updateExtensionMessages( $locFile, $extension, $verbose );
 48+ $result += self::updateExtensionMessages( $locFile, $extension, $verbose );
4949 }
5050
5151 // And output the result!
@@ -168,14 +168,21 @@
169169 }
170170
171171 public static function getFileContents( $basefile ) {
 172+ global $wgLocalisationUpdateRetryAttempts;
 173+ $attempts = 0;
172174 $basefilecontents = "";
173175 // use cURL to get the SVN contents
174176 if ( preg_match( "/^http/", $basefile ) ) {
175 - $basefilecontents = Http::get( $basefile );
176 - if ( empty( $basefilecontents ) ) {
177 - self::myLog( "Cannot get the contents of " . $basefile . " (curl)" );
178 - return false;
 177+ while(empty($basefilecontents) && $attempts < $wgLocalisationUpdateRetryAttempts) {
 178+ if($attempts > 0)
 179+ sleep(1);
 180+ $basefilecontents = Http::get( $basefile );
 181+ $attempts++;
179182 }
 183+ if ( empty( $basefilecontents ) ) {
 184+ self::myLog( "Cannot get the contents of " . $basefile . " (curl)" );
 185+ return false;
 186+ }
180187 } else {// otherwise try file_get_contents
181188 if ( !$basefilecontents = file_get_contents( $basefile ) ) {
182189 self::myLog( "Cannot get the contents of " . $basefile );

Status & tagging log