Index: branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php |
— | — | @@ -234,7 +234,8 @@ |
235 | 235 | * Load metadata from the file itself |
236 | 236 | */ |
237 | 237 | function loadFromFile() { |
238 | | - $this->setProps( self::getPropsFromPath( $this->getPath() ) ); |
| 238 | + $props = $this->repo->getFileProps( $this->getVirtualUrl() ); |
| 239 | + $this->setProps( $props ); |
239 | 240 | } |
240 | 241 | |
241 | 242 | function getCacheFields( $prefix = 'img_' ) { |
— | — | @@ -748,9 +749,8 @@ |
749 | 750 | # Check that the base file name is part of the thumb name |
750 | 751 | # This is a basic sanity check to avoid erasing unrelated directories |
751 | 752 | if ( strpos( $file, $this->getName() ) !== false ) { |
752 | | - wfSuppressWarnings(); |
753 | | - unlink( "$dir/$file" ); |
754 | | - wfRestoreWarnings(); |
| 753 | + $op = array( 'operation' => 'delete', 'source' => "$dir/$file" ); |
| 754 | + $this->repo->getBackend()->doOperations( array( $op ) ); |
755 | 755 | } |
756 | 756 | } |
757 | 757 | } |
Index: branches/FileBackend/phase3/includes/filerepo/file/TempFSFile.php |
— | — | @@ -2,24 +2,26 @@ |
3 | 3 | /** |
4 | 4 | * @file |
5 | 5 | * @ingroup FileRepo |
| 6 | + * @ingroup FileBackend |
6 | 7 | */ |
7 | 8 | |
8 | 9 | /** |
9 | 10 | * This class is used to hold the location and do limited manipulation |
10 | 11 | * of files stored temporarily (usually this will be $wgTmpDirectory) |
| 12 | + * |
| 13 | + * @ingroup FileRepo |
| 14 | + * @ingroup FileBackend |
11 | 15 | */ |
12 | 16 | class TempFSFile extends FSFile { |
13 | | - protected $canDelete; // whether this object should garbage collect the temp file |
| 17 | + protected $canDelete = true; // garbage collect the temp file |
14 | 18 | |
15 | 19 | /** |
16 | | - * Sets up the temporary file object |
| 20 | + * Flag to not clean up after the temporary file |
17 | 21 | * |
18 | | - * @param String $path Path to temporary file on local disk |
19 | | - * @param Boolean $canDelete Whether this object should garbage collect the temp file |
| 22 | + * @return void |
20 | 23 | */ |
21 | | - public function __construct( $path, $canDelete = true ) { |
22 | | - $this->path = $path; |
23 | | - $this->canDelete = $canDelete; |
| 24 | + public function preserve() { |
| 25 | + $this->canDelete = false; |
24 | 26 | } |
25 | 27 | |
26 | 28 | /** |
Index: branches/FileBackend/phase3/includes/filerepo/file/FSFile.php |
— | — | @@ -2,10 +2,14 @@ |
3 | 3 | /** |
4 | 4 | * @file |
5 | 5 | * @ingroup FileRepo |
| 6 | + * @ingroup FileBackend |
6 | 7 | */ |
7 | 8 | |
8 | 9 | /** |
9 | 10 | * Class representing a non-directory file on the file system |
| 11 | + * |
| 12 | + * @ingroup FileRepo |
| 13 | + * @ingroup FileBackend |
10 | 14 | */ |
11 | 15 | class FSFile { |
12 | 16 | protected $path; // path to file |
— | — | @@ -38,6 +42,19 @@ |
39 | 43 | } |
40 | 44 | |
41 | 45 | /** |
| 46 | + * Get the file's last-modified timestamp |
| 47 | + * |
| 48 | + * @return string|false TS_MW timestamp or false on failure |
| 49 | + */ |
| 50 | + public function getTimestamp() { |
| 51 | + $timestamp = filemtime( $this->path ); |
| 52 | + if ( $timestamp !== false ) { |
| 53 | + $timestamp = wfTimestamp( TS_MW, $ts ); |
| 54 | + } |
| 55 | + return $timestamp; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
42 | 59 | * Get an associative array containing information about |
43 | 60 | * a file with the given storage path. |
44 | 61 | * |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * @file |
5 | 5 | * @ingroup FileRepo |
| 6 | + * @ingroup FileBackend |
6 | 7 | */ |
7 | 8 | |
8 | 9 | /** |
— | — | @@ -20,6 +21,9 @@ |
21 | 22 | * |
22 | 23 | * All write operations are performed on all backends. |
23 | 24 | * If an operation fails on one backend it will be rolled back from the others. |
| 25 | + * |
| 26 | + * @ingroup FileRepo |
| 27 | + * @ingroup FileBackend |
24 | 28 | */ |
25 | 29 | class FileBackendMultiWrite extends FileBackendBase { |
26 | 30 | /** @var Array Prioritized list of FileBackend objects */ |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php |
— | — | @@ -2,12 +2,16 @@ |
3 | 3 | /** |
4 | 4 | * @file |
5 | 5 | * @ingroup FileRepo |
| 6 | + * @ingroup FileBackend |
6 | 7 | */ |
7 | 8 | |
8 | 9 | /** |
9 | 10 | * Class for a file-system based file backend. |
10 | 11 | * Status messages should avoid mentioning the internal FS paths. |
11 | 12 | * Likewise, error suppression should be used to path disclosure. |
| 13 | + * |
| 14 | + * @ingroup FileRepo |
| 15 | + * @ingroup FileBackend |
12 | 16 | */ |
13 | 17 | class FSFileBackend extends FileBackend { |
14 | 18 | /** @var Array Map of container names to paths */ |
— | — | @@ -307,12 +311,10 @@ |
308 | 312 | if ( !wfMkdirParents( $dir ) ) { |
309 | 313 | $status->fatal( 'directorycreateerror', $param['directory'] ); |
310 | 314 | return $status; |
311 | | - } |
312 | | - if ( !is_writable( $dir ) ) { |
| 315 | + } elseif ( !is_writable( $dir ) ) { |
313 | 316 | $status->fatal( 'directoryreadonlyerror', $param['directory'] ); |
314 | 317 | return $status; |
315 | | - } |
316 | | - if ( !is_readable( $dir ) ) { |
| 318 | + } elseif ( !is_readable( $dir ) ) { |
317 | 319 | $status->fatal( 'directorynotreadableerror', $param['directory'] ); |
318 | 320 | return $status; |
319 | 321 | } |
— | — | @@ -373,13 +375,22 @@ |
374 | 376 | return md5_file( $source ); |
375 | 377 | } |
376 | 378 | |
| 379 | + function getFileTimestamp( array $params ) { |
| 380 | + list( $c, $source ) = $this->resolveVirtualPath( $params['source'] ); |
| 381 | + if ( $source === null ) { |
| 382 | + return false; // invalid storage path |
| 383 | + } |
| 384 | + $fsFile = new FSFile( $source ); |
| 385 | + return $fsFile->getTimestamp(); |
| 386 | + } |
| 387 | + |
377 | 388 | function getFileProps( array $params ) { |
378 | | - $tmpFile = $this->getLocalCopy( $params ); |
379 | | - if ( !$tmpFile ) { |
380 | | - return FSFile::placeholderProps(); |
381 | | - } else { |
382 | | - return $tmpFile->getProps(); |
| 389 | + list( $c, $source ) = $this->resolveVirtualPath( $params['source'] ); |
| 390 | + if ( $source === null ) { |
| 391 | + return FSFile::placeholderProps(); // invalid storage path |
383 | 392 | } |
| 393 | + $fsFile = new FSFile( $source ); |
| 394 | + return $fsFile->getProps(); |
384 | 395 | } |
385 | 396 | |
386 | 397 | function getFileList( array $params ) { |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * @file |
5 | 5 | * @ingroup FileRepo |
| 6 | + * @ingroup FileBackend |
6 | 7 | */ |
7 | 8 | |
8 | 9 | /** |
— | — | @@ -16,6 +17,9 @@ |
17 | 18 | * |
18 | 19 | * Methods should avoid throwing exceptions at all costs. |
19 | 20 | * As a corollary, external dependencies should be kept to a minimum. |
| 21 | + * |
| 22 | + * @ingroup FileRepo |
| 23 | + * @ingroup FileBackend |
20 | 24 | */ |
21 | 25 | abstract class FileBackendBase { |
22 | 26 | protected $name; // unique backend name |
— | — | @@ -111,13 +115,13 @@ |
112 | 116 | abstract public function fileExists( array $params ); |
113 | 117 | |
114 | 118 | /** |
115 | | - * Get a hash of the file that exists at a storage path in the backend. |
| 119 | + * Get a hash of the file at a storage path in the backend. |
116 | 120 | * Typically this will be a SHA-1 hash, MD5 hash, or something similar. |
117 | 121 | * $params include: |
118 | 122 | * source : source storage path |
119 | 123 | * |
120 | 124 | * @param Array $params |
121 | | - * @return string|null Gives null if the file does not exist |
| 125 | + * @return string|false Hash string or false on failure |
122 | 126 | */ |
123 | 127 | abstract public function getFileHash( array $params ); |
124 | 128 | |
— | — | @@ -129,17 +133,28 @@ |
130 | 134 | abstract public function getHashType(); |
131 | 135 | |
132 | 136 | /** |
133 | | - * Get the properties of the file that exists at a storage path in the backend |
| 137 | + * Get the last-modified timestamp of the file at a storage path. |
134 | 138 | * $params include: |
135 | 139 | * source : source storage path |
136 | 140 | * |
137 | 141 | * @param Array $params |
138 | | - * @return Array|null Gives null if the file does not exist |
| 142 | + * @return string|false TS_MW timestamp or false on failure |
139 | 143 | */ |
| 144 | + abstract public function getFileTimestamp( array $params ); |
| 145 | + |
| 146 | + /** |
| 147 | + * Get the properties of the file at a storage path in the backend. |
| 148 | + * Returns FSFile::placeholderProps() on failure. |
| 149 | + * $params include: |
| 150 | + * source : source storage path |
| 151 | + * |
| 152 | + * @param Array $params |
| 153 | + * @return Array |
| 154 | + */ |
140 | 155 | abstract public function getFileProps( array $params ); |
141 | 156 | |
142 | 157 | /** |
143 | | - * Stream the file that exists at a storage path in the backend. |
| 158 | + * Stream the file at a storage path in the backend. |
144 | 159 | * Appropriate HTTP headers (Status, Content-Type, Content-Length) |
145 | 160 | * must be sent if streaming began, while none should be sent otherwise. |
146 | 161 | * Implementations should flush the output buffer before sending data. |
— | — | @@ -202,6 +217,9 @@ |
203 | 218 | /** |
204 | 219 | * Base class for all single-write backends. |
205 | 220 | * This class defines the methods as abstract that subclasses must implement. |
| 221 | + * |
| 222 | + * @ingroup FileRepo |
| 223 | + * @ingroup FileBackend |
206 | 224 | */ |
207 | 225 | abstract class FileBackend extends FileBackendBase { |
208 | 226 | /** |
— | — | @@ -308,6 +326,15 @@ |
309 | 327 | return false; // not implemented |
310 | 328 | } |
311 | 329 | |
| 330 | + public function getFileProps( array $params ) { |
| 331 | + $tmpFile = $this->getLocalCopy( $params ); |
| 332 | + if ( !$tmpFile ) { |
| 333 | + return FSFile::placeholderProps(); |
| 334 | + } else { |
| 335 | + return $tmpFile->getProps(); |
| 336 | + } |
| 337 | + } |
| 338 | + |
312 | 339 | /** |
313 | 340 | * Get the list of supported operations and their corresponding FileOp classes. |
314 | 341 | * |
— | — | @@ -482,7 +509,7 @@ |
483 | 510 | * |
484 | 511 | * @param $container string |
485 | 512 | * @param $relStoragePath string |
486 | | - * @return string|null Null if path is not valid |
| 513 | + * @return string|null Path or null if not valid |
487 | 514 | */ |
488 | 515 | protected function resolveContainerPath( $container, $relStoragePath ) { |
489 | 516 | return $relStoragePath; |
Index: branches/FileBackend/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | * @param $url string |
217 | 217 | * @return bool |
218 | 218 | */ |
219 | | - static function isVirtualUrl( $url ) { |
| 219 | + public static function isVirtualUrl( $url ) { |
220 | 220 | return substr( $url, 0, 9 ) == 'mwrepo://'; |
221 | 221 | } |
222 | 222 | |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | * @param $suffix string |
229 | 229 | * @return string |
230 | 230 | */ |
231 | | - function getVirtualUrl( $suffix = false ) { |
| 231 | + public function getVirtualUrl( $suffix = false ) { |
232 | 232 | $path = 'mwrepo://' . $this->name; |
233 | 233 | if ( $suffix !== false ) { |
234 | 234 | $path .= '/' . rawurlencode( $suffix ); |
— | — | @@ -241,7 +241,7 @@ |
242 | 242 | * @param $zone String: one of: public, deleted, temp, thumb |
243 | 243 | * @return String or false |
244 | 244 | */ |
245 | | - function getZoneUrl( $zone ) { |
| 245 | + public function getZoneUrl( $zone ) { |
246 | 246 | switch ( $zone ) { |
247 | 247 | case 'public': |
248 | 248 | return $this->url; |
— | — | @@ -300,7 +300,7 @@ |
301 | 301 | * @param $zone string |
302 | 302 | * @return string|null |
303 | 303 | */ |
304 | | - function getZonePath( $zone ) { |
| 304 | + public function getZonePath( $zone ) { |
305 | 305 | list( $container, $base ) = $this->getZoneLocation( $zone ); |
306 | 306 | if ( $container === null || $base === null ) { |
307 | 307 | return null; |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | * should return false if this parameter is set. |
322 | 322 | * @return File|null A File, or null if passed an invalid Title |
323 | 323 | */ |
324 | | - function newFile( $title, $time = false ) { |
| 324 | + public function newFile( $title, $time = false ) { |
325 | 325 | $title = File::normalizeTitle( $title ); |
326 | 326 | if ( !$title ) { |
327 | 327 | return null; |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | * be found. |
356 | 356 | * @return File|false |
357 | 357 | */ |
358 | | - function findFile( $title, $options = array() ) { |
| 358 | + public function findFile( $title, $options = array() ) { |
359 | 359 | $title = File::normalizeTitle( $title ); |
360 | 360 | if ( !$title ) { |
361 | 361 | return false; |
— | — | @@ -409,7 +409,7 @@ |
410 | 410 | * $repo->findFiles( $findBatch ); |
411 | 411 | * @return array |
412 | 412 | */ |
413 | | - function findFiles( $items ) { |
| 413 | + public function findFiles( $items ) { |
414 | 414 | $result = array(); |
415 | 415 | foreach ( $items as $item ) { |
416 | 416 | if ( is_array( $item ) ) { |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | * @param $options Option array, same as findFile(). |
439 | 439 | * @return File|false |
440 | 440 | */ |
441 | | - function findFileFromKey( $sha1, $options = array() ) { |
| 441 | + public function findFileFromKey( $sha1, $options = array() ) { |
442 | 442 | $time = isset( $options['time'] ) ? $options['time'] : false; |
443 | 443 | |
444 | 444 | # First try to find a matching current version of a file... |
— | — | @@ -468,7 +468,7 @@ |
469 | 469 | * |
470 | 470 | * @return string |
471 | 471 | */ |
472 | | - function getRootUrl() { |
| 472 | + public function getRootUrl() { |
473 | 473 | return $this->url; |
474 | 474 | } |
475 | 475 | |
— | — | @@ -477,7 +477,7 @@ |
478 | 478 | * |
479 | 479 | * @return string |
480 | 480 | */ |
481 | | - function isHashed() { |
| 481 | + public function isHashed() { |
482 | 482 | return (bool)$this->hashLevels; |
483 | 483 | } |
484 | 484 | |
— | — | @@ -486,7 +486,7 @@ |
487 | 487 | * |
488 | 488 | * @return string |
489 | 489 | */ |
490 | | - function getThumbScriptUrl() { |
| 490 | + public function getThumbScriptUrl() { |
491 | 491 | return $this->thumbScriptUrl; |
492 | 492 | } |
493 | 493 | |
— | — | @@ -495,7 +495,7 @@ |
496 | 496 | * |
497 | 497 | * @return bool |
498 | 498 | */ |
499 | | - function canTransformVia404() { |
| 499 | + public function canTransformVia404() { |
500 | 500 | return $this->transformVia404; |
501 | 501 | } |
502 | 502 | |
— | — | @@ -504,9 +504,9 @@ |
505 | 505 | * |
506 | 506 | * @param $title Title |
507 | 507 | */ |
508 | | - function getNameFromTitle( Title $title ) { |
| 508 | + public function getNameFromTitle( Title $title ) { |
| 509 | + global $wgContLang; |
509 | 510 | if ( $this->initialCapital != MWNamespace::isCapitalized( NS_FILE ) ) { |
510 | | - global $wgContLang; |
511 | 511 | $name = $title->getUserCaseDBKey(); |
512 | 512 | if ( $this->initialCapital ) { |
513 | 513 | $name = $wgContLang->ucfirst( $name ); |
— | — | @@ -536,11 +536,11 @@ |
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
540 | | - * Get the public root directory of the repository. |
| 540 | + * Get the public zone root directory of the repository. |
541 | 541 | * |
542 | 542 | * @return string |
543 | 543 | */ |
544 | | - function getRootDirectory() { |
| 544 | + public function getRootDirectory() { |
545 | 545 | return $this->getZonePath( 'public' ); |
546 | 546 | } |
547 | 547 | |
— | — | @@ -551,7 +551,7 @@ |
552 | 552 | * @param $name string |
553 | 553 | * @return string |
554 | 554 | */ |
555 | | - function getHashPath( $name ) { |
| 555 | + public function getHashPath( $name ) { |
556 | 556 | return self::getHashPathForLevel( $name, $this->hashLevels ); |
557 | 557 | } |
558 | 558 | |
— | — | @@ -560,7 +560,7 @@ |
561 | 561 | * |
562 | 562 | * @return string |
563 | 563 | */ |
564 | | - function getName() { |
| 564 | + public function getName() { |
565 | 565 | return $this->name; |
566 | 566 | } |
567 | 567 | |
— | — | @@ -571,7 +571,7 @@ |
572 | 572 | * @param $entry string Entry point; defaults to index |
573 | 573 | * @return string |
574 | 574 | */ |
575 | | - function makeUrl( $query = '', $entry = 'index' ) { |
| 575 | + public function makeUrl( $query = '', $entry = 'index' ) { |
576 | 576 | $ext = isset( $this->scriptExtension ) ? $this->scriptExtension : '.php'; |
577 | 577 | return wfAppendQuery( "{$this->scriptDirUrl}/{$entry}{$ext}", $query ); |
578 | 578 | } |
— | — | @@ -588,7 +588,7 @@ |
589 | 589 | * @param $name string |
590 | 590 | * @return string |
591 | 591 | */ |
592 | | - function getDescriptionUrl( $name ) { |
| 592 | + public function getDescriptionUrl( $name ) { |
593 | 593 | $encName = wfUrlencode( $name ); |
594 | 594 | if ( !is_null( $this->descBaseUrl ) ) { |
595 | 595 | # "http://example.com/wiki/Image:" |
— | — | @@ -623,7 +623,7 @@ |
624 | 624 | * @param $lang String: language to fetch it in, if any. |
625 | 625 | * @return string |
626 | 626 | */ |
627 | | - function getDescriptionRenderUrl( $name, $lang = null ) { |
| 627 | + public function getDescriptionRenderUrl( $name, $lang = null ) { |
628 | 628 | $query = 'action=render'; |
629 | 629 | if ( !is_null( $lang ) ) { |
630 | 630 | $query .= '&uselang=' . $lang; |
— | — | @@ -645,9 +645,10 @@ |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * Get the URL of the stylesheet to apply to description pages |
| 649 | + * |
649 | 650 | * @return string |
650 | 651 | */ |
651 | | - function getDescriptionStylesheetUrl() { |
| 652 | + public function getDescriptionStylesheetUrl() { |
652 | 653 | if ( $this->scriptDirUrl ) { |
653 | 654 | return $this->makeUrl( 'title=MediaWiki:Filepage.css&' . |
654 | 655 | wfArrayToCGI( Skin::getDynamicStylesheetQuery() ) ); |
— | — | @@ -667,7 +668,7 @@ |
668 | 669 | * same contents as the source |
669 | 670 | * @return FileRepoStatus |
670 | 671 | */ |
671 | | - function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) { |
| 672 | + public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) { |
672 | 673 | $status = $this->storeBatch( array( array( $srcPath, $dstZone, $dstRel ) ), $flags ); |
673 | 674 | if ( $status->successCount == 0 ) { |
674 | 675 | $status->ok = false; |
— | — | @@ -686,7 +687,7 @@ |
687 | 688 | * same contents as the source |
688 | 689 | * @return FileRepoStatus |
689 | 690 | */ |
690 | | - function storeBatch( $triplets, $flags = 0 ) { |
| 691 | + public function storeBatch( $triplets, $flags = 0 ) { |
691 | 692 | $backend = $this->backend; // convenience |
692 | 693 | |
693 | 694 | // Try creating directories |
— | — | @@ -767,7 +768,7 @@ |
768 | 769 | * @param $pairs array List of files to delete |
769 | 770 | * @return void |
770 | 771 | */ |
771 | | - function cleanupBatch( $files ) { |
| 772 | + public function cleanupBatch( $files ) { |
772 | 773 | $operations = array(); |
773 | 774 | $sourceFSFilesToDelete = array(); // cleanup for disk source files |
774 | 775 | foreach ( $files as $file ) { |
— | — | @@ -815,7 +816,7 @@ |
816 | 817 | * @param $srcPath String: the current location of the file. |
817 | 818 | * @return FileRepoStatus object with the URL in the value. |
818 | 819 | */ |
819 | | - function storeTemp( $originalName, $srcPath ) { |
| 820 | + public function storeTemp( $originalName, $srcPath ) { |
820 | 821 | $date = gmdate( "YmdHis" ); |
821 | 822 | $hashPath = $this->getHashPath( $originalName ); |
822 | 823 | $dstRel = "{$hashPath}{$date}!{$originalName}"; |
— | — | @@ -831,7 +832,7 @@ |
832 | 833 | * @param $virtualUrl String: the virtual URL returned by storeTemp |
833 | 834 | * @return Boolean: true on success, false on failure |
834 | 835 | */ |
835 | | - function freeTemp( $virtualUrl ) { |
| 836 | + public function freeTemp( $virtualUrl ) { |
836 | 837 | $temp = "mwrepo://{$this->name}/temp"; |
837 | 838 | if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) { |
838 | 839 | wfDebug( __METHOD__.": Invalid temp virtual URL\n" ); |
— | — | @@ -857,7 +858,7 @@ |
858 | 859 | * @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate |
859 | 860 | * that the source file should be deleted if possible |
860 | 861 | */ |
861 | | - function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) { |
| 862 | + public function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) { |
862 | 863 | $status = $this->publishBatch( array( array( $srcPath, $dstRel, $archiveRel ) ), $flags ); |
863 | 864 | if ( $status->successCount == 0 ) { |
864 | 865 | $status->ok = false; |
— | — | @@ -878,7 +879,7 @@ |
879 | 880 | * that the source files should be deleted if possible |
880 | 881 | * @return FileRepoStatus |
881 | 882 | */ |
882 | | - function publishBatch( $triplets, $flags = 0 ) { |
| 883 | + public function publishBatch( $triplets, $flags = 0 ) { |
883 | 884 | $backend = $this->backend; // convenience |
884 | 885 | |
885 | 886 | // Try creating directories |
— | — | @@ -978,7 +979,7 @@ |
979 | 980 | * self::FILES_ONLY Mark file as existing only if it is a file (not directory) |
980 | 981 | * @return bool |
981 | 982 | */ |
982 | | - function fileExists( $file, $flags = 0 ) { |
| 983 | + public function fileExists( $file, $flags = 0 ) { |
983 | 984 | $result = $this->fileExistsBatch( array( $file ), $flags ); |
984 | 985 | return $result[0]; |
985 | 986 | } |
— | — | @@ -991,7 +992,7 @@ |
992 | 993 | * self::FILES_ONLY Mark file as existing only if it is a file (not directory) |
993 | 994 | * @return Either array of files and existence flags, or false |
994 | 995 | */ |
995 | | - function fileExistsBatch( $files, $flags = 0 ) { |
| 996 | + public function fileExistsBatch( $files, $flags = 0 ) { |
996 | 997 | if ( !$this->initZones() ) { |
997 | 998 | return false; |
998 | 999 | } |
— | — | @@ -1024,7 +1025,7 @@ |
1025 | 1026 | * Relative to a private archive directory. |
1026 | 1027 | * @return FileRepoStatus object |
1027 | 1028 | */ |
1028 | | - function delete( $srcRel, $archiveRel ) { |
| 1029 | + public function delete( $srcRel, $archiveRel ) { |
1029 | 1030 | return $this->deleteBatch( array( array( $srcRel, $archiveRel ) ) ); |
1030 | 1031 | } |
1031 | 1032 | |
— | — | @@ -1044,7 +1045,7 @@ |
1045 | 1046 | * to the deleted zone root in the second element. |
1046 | 1047 | * @return FileRepoStatus |
1047 | 1048 | */ |
1048 | | - function deleteBatch( $sourceDestPairs ) { |
| 1049 | + public function deleteBatch( $sourceDestPairs ) { |
1049 | 1050 | $backend = $this->backend; // convenience |
1050 | 1051 | |
1051 | 1052 | if ( !isset( $this->zones['deleted'] ) ) { |
— | — | @@ -1111,7 +1112,7 @@ |
1112 | 1113 | * |
1113 | 1114 | * @return string |
1114 | 1115 | */ |
1115 | | - function getDeletedHashPath( $key ) { |
| 1116 | + public function getDeletedHashPath( $key ) { |
1116 | 1117 | $path = ''; |
1117 | 1118 | for ( $i = 0; $i < $this->deletedHashLevels; $i++ ) { |
1118 | 1119 | $path .= $key[$i] . '/'; |
— | — | @@ -1122,12 +1123,12 @@ |
1123 | 1124 | /** |
1124 | 1125 | * Get properties of a file with a given virtual URL |
1125 | 1126 | * The virtual URL must refer to this repo |
1126 | | - * Properties should ultimately be obtained via File::getPropsFromPath() |
| 1127 | + * Properties should ultimately be obtained via FSFile::getProps() |
1127 | 1128 | * |
1128 | 1129 | * @param $virtualUrl string |
1129 | 1130 | * @return Array |
1130 | 1131 | */ |
1131 | | - function getFileProps( $virtualUrl ) { |
| 1132 | + public function getFileProps( $virtualUrl ) { |
1132 | 1133 | $path = $this->resolveVirtualUrl( $virtualUrl ); |
1133 | 1134 | return $this->backend->getFileProps( $path ); |
1134 | 1135 | } |
— | — | @@ -1139,7 +1140,7 @@ |
1140 | 1141 | * @param $callback Array|string |
1141 | 1142 | * @return void |
1142 | 1143 | */ |
1143 | | - function enumFiles( $callback ) { |
| 1144 | + public function enumFiles( $callback ) { |
1144 | 1145 | return $this->enumFilesInStorage( $callback ); |
1145 | 1146 | } |
1146 | 1147 | |
— | — | @@ -1150,7 +1151,7 @@ |
1151 | 1152 | * @param $callback Array|string |
1152 | 1153 | * @return void |
1153 | 1154 | */ |
1154 | | - function enumFilesInStorage( $callback ) { |
| 1155 | + protected function enumFilesInStorage( $callback ) { |
1155 | 1156 | $publicRoot = $this->getZonePath( 'public' ); |
1156 | 1157 | $numDirs = 1 << ( $this->hashLevels * 4 ); |
1157 | 1158 | // Use a priori assumptions about directory structure |
— | — | @@ -1175,7 +1176,7 @@ |
1176 | 1177 | * @param $filename string |
1177 | 1178 | * @return bool |
1178 | 1179 | */ |
1179 | | - function validateFilename( $filename ) { |
| 1180 | + public function validateFilename( $filename ) { |
1180 | 1181 | if ( strval( $filename ) == '' ) { |
1181 | 1182 | return false; |
1182 | 1183 | } |
— | — | @@ -1284,7 +1285,7 @@ |
1285 | 1286 | * |
1286 | 1287 | * STUB |
1287 | 1288 | */ |
1288 | | - function cleanupDeletedBatch( $storageKeys ) {} |
| 1289 | + public function cleanupDeletedBatch( $storageKeys ) {} |
1289 | 1290 | |
1290 | 1291 | /** |
1291 | 1292 | * Checks if there is a redirect named as $title. If there is, return the |
— | — | @@ -1294,7 +1295,7 @@ |
1295 | 1296 | * @param $title Title of image |
1296 | 1297 | * @return Bool |
1297 | 1298 | */ |
1298 | | - function checkRedirect( Title $title ) { |
| 1299 | + public function checkRedirect( Title $title ) { |
1299 | 1300 | return false; |
1300 | 1301 | } |
1301 | 1302 | |
— | — | @@ -1305,7 +1306,7 @@ |
1306 | 1307 | * STUB |
1307 | 1308 | * @param $title Title of image |
1308 | 1309 | */ |
1309 | | - function invalidateImageRedirect( Title $title ) {} |
| 1310 | + public function invalidateImageRedirect( Title $title ) {} |
1310 | 1311 | |
1311 | 1312 | /** |
1312 | 1313 | * Get an array or iterator of file objects for files that have a given |
— | — | @@ -1313,7 +1314,7 @@ |
1314 | 1315 | * |
1315 | 1316 | * STUB |
1316 | 1317 | */ |
1317 | | - function findBySha1( $hash ) { |
| 1318 | + public function findBySha1( $hash ) { |
1318 | 1319 | return array(); |
1319 | 1320 | } |
1320 | 1321 | |
— | — | @@ -1336,7 +1337,7 @@ |
1337 | 1338 | * |
1338 | 1339 | * @return bool |
1339 | 1340 | */ |
1340 | | - function isLocal() { |
| 1341 | + public function isLocal() { |
1341 | 1342 | return $this->getName() == 'local'; |
1342 | 1343 | } |
1343 | 1344 | |
— | — | @@ -1355,6 +1356,8 @@ |
1356 | 1357 | * Get a key for this repo in the local cache domain. These cache keys are |
1357 | 1358 | * not shared with remote instances of the repo. |
1358 | 1359 | * The parameters are the parts of the key, as for wfMemcKey(). |
| 1360 | + * |
| 1361 | + * @return string |
1359 | 1362 | */ |
1360 | 1363 | function getLocalCacheKey( /*...*/ ) { |
1361 | 1364 | $args = func_get_args(); |
— | — | @@ -1367,7 +1370,7 @@ |
1368 | 1371 | * |
1369 | 1372 | * @return UploadStash |
1370 | 1373 | */ |
1371 | | - function getUploadStash() { |
| 1374 | + public function getUploadStash() { |
1372 | 1375 | return new UploadStash( $this ); |
1373 | 1376 | } |
1374 | 1377 | } |