r94545 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94544‎ | r94545 | r94546 >
Date:18:51, 15 August 2011
Author:reedy
Status:ok
Tags:
Comment:
Fixup some whitespace

Add a couple of FIXMEs where variables are undefined

Swap newGood() for Status::newGood()
Modified paths:
  • /trunk/extensions/SwiftMedia/SwiftMedia.body.php (modified) (history)
  • /trunk/extensions/SwiftMedia/SwiftMedia.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/SwiftMedia.php
@@ -1,18 +1,18 @@
22 <?php
33 $wgExtensionCredits['other'][] = array(
4 - 'path' => __FILE__, // File name for the extension itself, required for getting the revision number from SVN - string, adding in 1.15
5 - 'name' => "SwiftMedia", // Name of extension - string
6 - 'descriptionmsg' => "swiftmedia", // Same as above but name of a message, for i18n - string, added in 1.12.0
7 - 'version' => 0, // Version number of extension - number or string
8 - 'author' => "Russ Nelson", // The extension author's name - string or array for multiple
9 - 'url' => "http://www.mediawiki.org/wiki/Extension:SwiftMedia", // URL of extension (usually instructions) - string
 4+ 'path' => __FILE__, // File name for the extension itself, required for getting the revision number from SVN - string, adding in 1.15
 5+ 'name' => "SwiftMedia", // Name of extension - string
 6+ 'descriptionmsg' => "swiftmedia", // Same as above but name of a message, for i18n - string, added in 1.12.0
 7+ 'version' => 0, // Version number of extension - number or string
 8+ 'author' => "Russ Nelson", // The extension author's name - string or array for multiple
 9+ 'url' => "http://www.mediawiki.org/wiki/Extension:SwiftMedia", // URL of extension (usually instructions) - string
1010 );
1111
12 -$wgAutoloadClasses['SwiftFile'] =
13 -$wgAutoloadClasses['SwiftRepo'] = dirname(__FILE__) . '/SwiftMedia.body.php';
14 -$wgAutoloadClasses['CF_Authentication'] =
15 -$wgAutoloadClasses['CF_Connection'] =
16 -$wgAutoloadClasses['CF_Container'] =
17 -$wgAutoloadClasses['CF_Object'] = '/usr/share/php-cloudfiles/cloudfiles.php';
 12+$wgAutoloadClasses['SwiftFile'] =
 13+ $wgAutoloadClasses['SwiftRepo'] = dirname(__FILE__) . '/SwiftMedia.body.php';
 14+$wgAutoloadClasses['CF_Authentication'] =
 15+ $wgAutoloadClasses['CF_Connection'] =
 16+ $wgAutoloadClasses['CF_Container'] =
 17+ $wgAutoloadClasses['CF_Object'] = '/usr/share/php-cloudfiles/cloudfiles.php';
1818
1919 $wgExtensionMessagesFiles['swiftmedia'] = dirname( __FILE__ ) . '/SwiftMedia.i18n.php';
Index: trunk/extensions/SwiftMedia/SwiftMedia.body.php
@@ -176,7 +176,7 @@
177177 $container = $this->repo->get_container($conn,$this->repo->container . "%2Fthumb");
178178 $this->repo->write_swift_object( $thumbTemp, $container, $this->getRel() . "/" . $thumbName);
179179 // php-cloudfiles throws exceptions, so failure never gets here.
180 -
 180+
181181 // Clean up temporary data.
182182 unlink($thumbTemp);
183183
@@ -238,7 +238,7 @@
239239 //if ( in_array( $ext, $wgExcludeFromThumbnailPurge ) ) {
240240 // continue;
241241 //}
242 -
 242+
243243 $urls[] = $this->getThumbUrl($file);
244244 $this->repo->swift_delete($container, $file);
245245 }
@@ -345,9 +345,9 @@
346346 $obj = $dstc->create_object($dstRel);
347347 $obj->load_from_filename( $srcPath, True);
348348 } catch (SyntaxException $e) {
349 - throw new MWException( "missing required parameters" );
 349+ throw new MWException( "missing required parameters" );
350350 } catch (BadContentTypeException $e) {
351 - throw new MWException( "No Content-Type was/could be set" );
 351+ throw new MWException( "No Content-Type was/could be set" );
352352 } catch (InvalidResponseException $e) {
353353 throw new MWException( __METHOD__ . "unexpected response '$e'" );
354354 } catch (IOException $e) {
@@ -365,11 +365,11 @@
366366 try {
367367 $container->delete_object($rel);
368368 } catch (SyntaxException $e) {
369 - throw new MWException( "Swift object name not well-formed: '$e'" );
 369+ throw new MWException( "Swift object name not well-formed: '$e'" );
370370 } catch (NoSuchObjectException $e) {
371 - throw new MWException( "Swift object we are trying to delete does not exist: '$e'" );
 371+ throw new MWException( "Swift object we are trying to delete does not exist: '$e'" );
372372 } catch (InvalidResponseException $e) {
373 - throw new MWException( "unexpected response '$e'" );
 373+ throw new MWException( "unexpected response '$e'" );
374374 }
375375 }
376376
@@ -385,10 +385,10 @@
386386 * @return $status
387387 */
388388 function storeBatch( $triplets, $flags = 0 ) {
389 - wfDebug( __METHOD__ . ': Storing ' . count( $triplets ) .
 389+ wfDebug( __METHOD__ . ': Storing ' . count( $triplets ) .
390390 " triplets; flags: {$flags}\n" );
391 -
392 - // Validate each triplet
 391+
 392+ // Validate each triplet
393393 $status = $this->newGood();
394394 foreach ( $triplets as $i => $triplet ) {
395395 list( $srcPath, $dstZone, $dstRel ) = $triplet;
@@ -399,7 +399,7 @@
400400
401401 // Check overwriting
402402 if (0) { #FIXME
403 - if ( !( $flags & self::OVERWRITE ) && file_exists( $dstPath ) ) {
 403+ if ( !( $flags & self::OVERWRITE ) && file_exists( $dstPath ) ) { // FIXME: $dstPath is undefined
404404 if ( $flags & self::OVERWRITE_SAME ) {
405405 $hashSource = sha1_file( $srcPath );
406406 $hashDest = sha1_file( $dstPath );
@@ -445,15 +445,15 @@
446446 // php-cloudfiles throws exceptions, so failure never gets here.
447447 if ( $flags & self::DELETE_SOURCE ) {
448448 unlink ( $srcPath );
449 - }
 449+ }
450450 }
451451
452452 if ( !( $flags & self::SKIP_VALIDATION ) ) {
453453 // FIXME: Swift will return the MD5 of the data written.
454 - if (0) { // ( $hashDest === false || $hashSource !== $hashDest )
455 - wfDebug( __METHOD__ . ': File copy validation failed: ' .
 454+ if (0) { // ( $hashDest === false || $hashSource !== $hashDest )
 455+ wfDebug( __METHOD__ . ': File copy validation failed: ' .
456456 "$srcPath ($hashSource) to $dstPath ($hashDest)\n" );
457 -
 457+
458458 $status->error( 'filecopyerror', $srcPath, $dstPath );
459459 $good = false;
460460 }
@@ -491,7 +491,7 @@
492492
493493 // Do the append to the next name
494494 $status = $this->store( $srcPath, 'temp', sprintf("%s.%05d", $toAppendPath, $nextone) );
495 -
 495+
496496 if ( $flags & self::DELETE_SOURCE ) {
497497 unlink( $srcPath );
498498 }
@@ -504,8 +504,8 @@
505505 */
506506 function appendFinish( $toAppendPath ){
507507 $conn = $this->connect();
508 - $container = $this->repo->get_container( $conn,$this->repo->container . "%2Ftemp" );
509 - $parts = $container->list_objects( 0, NULL, $srcPath );
 508+ $container = $this->repo->get_container( $conn, $this->repo->container . "%2Ftemp" );
 509+ $parts = $container->list_objects( 0, NULL, $srcPath ); // FIXME: $srcPath is undefined
510510 // list_objects() returns a sorted list.
511511
512512 // The first object as the same name as the destination, so
@@ -520,7 +520,7 @@
521521 $obj = $container->get_object( $part );
522522 $biggie->write( $obj->read() );
523523 }
524 - return newGood();
 524+ return Status::newGood();
525525 }
526526
527527 /**
@@ -545,7 +545,7 @@
546546 list( $srcRel, $archiveRel ) = $pair;
547547
548548 $triplets[] = array( "mwrepo://{$this->name}/public/$srcRel", 'deleted', $archiveRel );
549 -
 549+
550550 }
551551 $status = $this->storeBatch( $triplets, FileRepo::OVERWRITE_SAME | FileRepo::DELETE_SOURCE );
552552 return $status;
@@ -700,7 +700,7 @@
701701 // php-cloudfiles throws exceptions, so failure never gets here.
702702 if ( $flags & self::DELETE_SOURCE ) {
703703 unlink ( $srcPath );
704 - }
 704+ }
705705 }
706706
707707 $good = true;
@@ -717,9 +717,9 @@
718718
719719 /**
720720 * Deletes a batch of files. Each file can be a (zone, rel) pairs, a
721 - * virtual url or a real path. It will try to delete each file, but
 721+ * virtual url or a real path. It will try to delete each file, but
722722 * ignores any errors that may occur
723 - *
 723+ *
724724 * @param $pairs array List of files to delete
725725 */
726726 function cleanupBatch( $files ) {
@@ -730,7 +730,7 @@
731731 list( $cont, $rel ) = $file;
732732 } else {
733733 if ( self::isVirtualUrl( $file ) ) {
734 - // This is a virtual url, resolve it
 734+ // This is a virtual url, resolve it
735735 $path = $this->getContainerRel( $file );
736736 list( $cont, $rel) = $path;
737737 } else {
@@ -738,7 +738,7 @@
739739 throw new MWException( __METHOD__.": $file needs an unlink()" );
740740 }
741741 }
742 -
 742+
743743 wfDebug( __METHOD__.": $cont/$rel\n" );
744744 $container = $this->get_container($conn,$cont);
745745 $this->swift_delete( $container, $rel );
@@ -900,11 +900,11 @@
901901 }
902902
903903
904 - /**
 904+ /**
905905 * Get properties of a file with a given virtual URL
906906 * The virtual URL must refer to this repo
907907 */
908 - function getFileProps( $virtualUrl ) {
 908+ function getFileProps( $virtualUrl ) {
909909 $path = $this->resolveVirtualUrl( $virtualUrl );
910910 $ret = File::getPropsFromPath( $path );
911911 unlink( $path );
@@ -1005,7 +1005,7 @@
10061006 return false;
10071007 }
10081008 }
1009 -
 1009+
10101010 /**
10111011 * Fields in the oldimage table
10121012 */

Status & tagging log