Index: trunk/extensions/SwiftMedia/SwiftMedia.php |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | <?php |
3 | 3 | $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 |
10 | 10 | ); |
11 | 11 | |
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'; |
18 | 18 | |
19 | 19 | $wgExtensionMessagesFiles['swiftmedia'] = dirname( __FILE__ ) . '/SwiftMedia.i18n.php'; |
Index: trunk/extensions/SwiftMedia/SwiftMedia.body.php |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | $container = $this->repo->get_container($conn,$this->repo->container . "%2Fthumb"); |
178 | 178 | $this->repo->write_swift_object( $thumbTemp, $container, $this->getRel() . "/" . $thumbName); |
179 | 179 | // php-cloudfiles throws exceptions, so failure never gets here. |
180 | | - |
| 180 | + |
181 | 181 | // Clean up temporary data. |
182 | 182 | unlink($thumbTemp); |
183 | 183 | |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | //if ( in_array( $ext, $wgExcludeFromThumbnailPurge ) ) { |
240 | 240 | // continue; |
241 | 241 | //} |
242 | | - |
| 242 | + |
243 | 243 | $urls[] = $this->getThumbUrl($file); |
244 | 244 | $this->repo->swift_delete($container, $file); |
245 | 245 | } |
— | — | @@ -345,9 +345,9 @@ |
346 | 346 | $obj = $dstc->create_object($dstRel); |
347 | 347 | $obj->load_from_filename( $srcPath, True); |
348 | 348 | } catch (SyntaxException $e) { |
349 | | - throw new MWException( "missing required parameters" ); |
| 349 | + throw new MWException( "missing required parameters" ); |
350 | 350 | } 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" ); |
352 | 352 | } catch (InvalidResponseException $e) { |
353 | 353 | throw new MWException( __METHOD__ . "unexpected response '$e'" ); |
354 | 354 | } catch (IOException $e) { |
— | — | @@ -365,11 +365,11 @@ |
366 | 366 | try { |
367 | 367 | $container->delete_object($rel); |
368 | 368 | } 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'" ); |
370 | 370 | } 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'" ); |
372 | 372 | } catch (InvalidResponseException $e) { |
373 | | - throw new MWException( "unexpected response '$e'" ); |
| 373 | + throw new MWException( "unexpected response '$e'" ); |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
— | — | @@ -385,10 +385,10 @@ |
386 | 386 | * @return $status |
387 | 387 | */ |
388 | 388 | function storeBatch( $triplets, $flags = 0 ) { |
389 | | - wfDebug( __METHOD__ . ': Storing ' . count( $triplets ) . |
| 389 | + wfDebug( __METHOD__ . ': Storing ' . count( $triplets ) . |
390 | 390 | " triplets; flags: {$flags}\n" ); |
391 | | - |
392 | | - // Validate each triplet |
| 391 | + |
| 392 | + // Validate each triplet |
393 | 393 | $status = $this->newGood(); |
394 | 394 | foreach ( $triplets as $i => $triplet ) { |
395 | 395 | list( $srcPath, $dstZone, $dstRel ) = $triplet; |
— | — | @@ -399,7 +399,7 @@ |
400 | 400 | |
401 | 401 | // Check overwriting |
402 | 402 | if (0) { #FIXME |
403 | | - if ( !( $flags & self::OVERWRITE ) && file_exists( $dstPath ) ) { |
| 403 | + if ( !( $flags & self::OVERWRITE ) && file_exists( $dstPath ) ) { // FIXME: $dstPath is undefined |
404 | 404 | if ( $flags & self::OVERWRITE_SAME ) { |
405 | 405 | $hashSource = sha1_file( $srcPath ); |
406 | 406 | $hashDest = sha1_file( $dstPath ); |
— | — | @@ -445,15 +445,15 @@ |
446 | 446 | // php-cloudfiles throws exceptions, so failure never gets here. |
447 | 447 | if ( $flags & self::DELETE_SOURCE ) { |
448 | 448 | unlink ( $srcPath ); |
449 | | - } |
| 449 | + } |
450 | 450 | } |
451 | 451 | |
452 | 452 | if ( !( $flags & self::SKIP_VALIDATION ) ) { |
453 | 453 | // 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: ' . |
456 | 456 | "$srcPath ($hashSource) to $dstPath ($hashDest)\n" ); |
457 | | - |
| 457 | + |
458 | 458 | $status->error( 'filecopyerror', $srcPath, $dstPath ); |
459 | 459 | $good = false; |
460 | 460 | } |
— | — | @@ -491,7 +491,7 @@ |
492 | 492 | |
493 | 493 | // Do the append to the next name |
494 | 494 | $status = $this->store( $srcPath, 'temp', sprintf("%s.%05d", $toAppendPath, $nextone) ); |
495 | | - |
| 495 | + |
496 | 496 | if ( $flags & self::DELETE_SOURCE ) { |
497 | 497 | unlink( $srcPath ); |
498 | 498 | } |
— | — | @@ -504,8 +504,8 @@ |
505 | 505 | */ |
506 | 506 | function appendFinish( $toAppendPath ){ |
507 | 507 | $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 |
510 | 510 | // list_objects() returns a sorted list. |
511 | 511 | |
512 | 512 | // The first object as the same name as the destination, so |
— | — | @@ -520,7 +520,7 @@ |
521 | 521 | $obj = $container->get_object( $part ); |
522 | 522 | $biggie->write( $obj->read() ); |
523 | 523 | } |
524 | | - return newGood(); |
| 524 | + return Status::newGood(); |
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
— | — | @@ -545,7 +545,7 @@ |
546 | 546 | list( $srcRel, $archiveRel ) = $pair; |
547 | 547 | |
548 | 548 | $triplets[] = array( "mwrepo://{$this->name}/public/$srcRel", 'deleted', $archiveRel ); |
549 | | - |
| 549 | + |
550 | 550 | } |
551 | 551 | $status = $this->storeBatch( $triplets, FileRepo::OVERWRITE_SAME | FileRepo::DELETE_SOURCE ); |
552 | 552 | return $status; |
— | — | @@ -700,7 +700,7 @@ |
701 | 701 | // php-cloudfiles throws exceptions, so failure never gets here. |
702 | 702 | if ( $flags & self::DELETE_SOURCE ) { |
703 | 703 | unlink ( $srcPath ); |
704 | | - } |
| 704 | + } |
705 | 705 | } |
706 | 706 | |
707 | 707 | $good = true; |
— | — | @@ -717,9 +717,9 @@ |
718 | 718 | |
719 | 719 | /** |
720 | 720 | * 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 |
722 | 722 | * ignores any errors that may occur |
723 | | - * |
| 723 | + * |
724 | 724 | * @param $pairs array List of files to delete |
725 | 725 | */ |
726 | 726 | function cleanupBatch( $files ) { |
— | — | @@ -730,7 +730,7 @@ |
731 | 731 | list( $cont, $rel ) = $file; |
732 | 732 | } else { |
733 | 733 | if ( self::isVirtualUrl( $file ) ) { |
734 | | - // This is a virtual url, resolve it |
| 734 | + // This is a virtual url, resolve it |
735 | 735 | $path = $this->getContainerRel( $file ); |
736 | 736 | list( $cont, $rel) = $path; |
737 | 737 | } else { |
— | — | @@ -738,7 +738,7 @@ |
739 | 739 | throw new MWException( __METHOD__.": $file needs an unlink()" ); |
740 | 740 | } |
741 | 741 | } |
742 | | - |
| 742 | + |
743 | 743 | wfDebug( __METHOD__.": $cont/$rel\n" ); |
744 | 744 | $container = $this->get_container($conn,$cont); |
745 | 745 | $this->swift_delete( $container, $rel ); |
— | — | @@ -900,11 +900,11 @@ |
901 | 901 | } |
902 | 902 | |
903 | 903 | |
904 | | - /** |
| 904 | + /** |
905 | 905 | * Get properties of a file with a given virtual URL |
906 | 906 | * The virtual URL must refer to this repo |
907 | 907 | */ |
908 | | - function getFileProps( $virtualUrl ) { |
| 908 | + function getFileProps( $virtualUrl ) { |
909 | 909 | $path = $this->resolveVirtualUrl( $virtualUrl ); |
910 | 910 | $ret = File::getPropsFromPath( $path ); |
911 | 911 | unlink( $path ); |
— | — | @@ -1005,7 +1005,7 @@ |
1006 | 1006 | return false; |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | | - |
| 1009 | + |
1010 | 1010 | /** |
1011 | 1011 | * Fields in the oldimage table |
1012 | 1012 | */ |