Index: trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php |
— | — | @@ -6,21 +6,27 @@ |
7 | 7 | class FileBackendTest extends MediaWikiTestCase { |
8 | 8 | private $backend, $multiBackend; |
9 | 9 | private $filesToPrune; |
| 10 | + private static $backendToUse; |
10 | 11 | |
11 | 12 | function setUp() { |
12 | 13 | global $wgFileBackends; |
13 | 14 | parent::setUp(); |
14 | 15 | $tmpDir = wfTempDir() . '/file-backend-test-' . time() . '-' . mt_rand(); |
15 | 16 | if ( $this->getCliArg( 'use-filebackend=' ) ) { |
16 | | - $name = $this->getCliArg( 'use-filebackend=' ); |
17 | | - $useConfig = array(); |
18 | | - foreach ( $wgFileBackends as $conf ) { |
19 | | - if ( $conf['name'] == $name ) { |
20 | | - $useConfig = $conf; |
| 17 | + if ( self::$backendToUse ) { |
| 18 | + $this->singleBackend = self::$backendToUse; |
| 19 | + } else { |
| 20 | + $name = $this->getCliArg( 'use-filebackend=' ); |
| 21 | + $useConfig = array(); |
| 22 | + foreach ( $wgFileBackends as $conf ) { |
| 23 | + if ( $conf['name'] == $name ) { |
| 24 | + $useConfig = $conf; |
| 25 | + } |
21 | 26 | } |
| 27 | + $useConfig['name'] = 'localtesting'; // swap name |
| 28 | + self::$backendToUse = new $conf['class']( $useConfig ); |
| 29 | + $this->singleBackend = self::$backendToUse; |
22 | 30 | } |
23 | | - $useConfig['name'] = 'localtesting'; // swap name |
24 | | - $this->singleBackend = new $conf['class']( $useConfig ); |
25 | 31 | } else { |
26 | 32 | $this->singleBackend = new FSFileBackend( array( |
27 | 33 | 'name' => 'localtesting', |
— | — | @@ -88,11 +94,16 @@ |
89 | 95 | $this->backend->prepare( array( 'dir' => dirname( $dest ) ) ); |
90 | 96 | |
91 | 97 | file_put_contents( $source, "Unit test file" ); |
| 98 | + |
| 99 | + if ( isset( $op['overwrite'] ) || isset( $op['overwriteSame'] ) ) { |
| 100 | + $this->backend->store( $op ); |
| 101 | + } |
| 102 | + |
92 | 103 | $status = $this->backend->doOperation( $op ); |
93 | 104 | |
94 | 105 | $this->assertEquals( array(), $status->errors, |
95 | 106 | "Store from $source to $dest succeeded without warnings ($backendName)." ); |
96 | | - $this->assertEquals( true, $status->isOK(), |
| 107 | + $this->assertEquals( array(), $status->errors, |
97 | 108 | "Store from $source to $dest succeeded ($backendName)." ); |
98 | 109 | $this->assertEquals( array( 0 => true ), $status->success, |
99 | 110 | "Store from $source to $dest has proper 'success' field in Status ($backendName)." ); |
— | — | @@ -123,14 +134,21 @@ |
124 | 135 | $toPath, // dest |
125 | 136 | ); |
126 | 137 | |
127 | | - $op['overwrite'] = true; |
| 138 | + $op2 = $op; |
| 139 | + $op2['overwrite'] = true; |
128 | 140 | $cases[] = array( |
129 | | - $op, // operation |
| 141 | + $op2, // operation |
130 | 142 | $tmpName, // source |
131 | 143 | $toPath, // dest |
132 | 144 | ); |
133 | 145 | |
134 | | - // @TODO: test overwriteSame |
| 146 | + $op2 = $op; |
| 147 | + $op2['overwriteSame'] = true; |
| 148 | + $cases[] = array( |
| 149 | + $op2, // operation |
| 150 | + $tmpName, // source |
| 151 | + $toPath, // dest |
| 152 | + ); |
135 | 153 | |
136 | 154 | return $cases; |
137 | 155 | } |
— | — | @@ -158,10 +176,15 @@ |
159 | 177 | |
160 | 178 | $status = $this->backend->doOperation( |
161 | 179 | array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) ); |
162 | | - $this->assertEquals( true, $status->isOK(), |
| 180 | + $this->assertEquals( array(), $status->errors, |
163 | 181 | "Creation of file at $source succeeded ($backendName)." ); |
164 | 182 | |
| 183 | + if ( isset( $op['overwrite'] ) || isset( $op['overwriteSame'] ) ) { |
| 184 | + $this->backend->copy( $op ); |
| 185 | + } |
| 186 | + |
165 | 187 | $status = $this->backend->doOperation( $op ); |
| 188 | + |
166 | 189 | $this->assertEquals( array(), $status->errors, |
167 | 190 | "Copy from $source to $dest succeeded without warnings ($backendName)." ); |
168 | 191 | $this->assertEquals( true, $status->isOK(), |
— | — | @@ -197,13 +220,22 @@ |
198 | 221 | $dest, // dest |
199 | 222 | ); |
200 | 223 | |
201 | | - $op['overwrite'] = true; |
| 224 | + $op2 = $op; |
| 225 | + $op2['overwrite'] = true; |
202 | 226 | $cases[] = array( |
203 | | - $op, // operation |
| 227 | + $op2, // operation |
204 | 228 | $source, // source |
205 | 229 | $dest, // dest |
206 | 230 | ); |
207 | 231 | |
| 232 | + $op2 = $op; |
| 233 | + $op2['overwriteSame'] = true; |
| 234 | + $cases[] = array( |
| 235 | + $op2, // operation |
| 236 | + $source, // source |
| 237 | + $dest, // dest |
| 238 | + ); |
| 239 | + |
208 | 240 | return $cases; |
209 | 241 | } |
210 | 242 | |
— | — | @@ -230,9 +262,13 @@ |
231 | 263 | |
232 | 264 | $status = $this->backend->doOperation( |
233 | 265 | array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) ); |
234 | | - $this->assertEquals( true, $status->isOK(), |
| 266 | + $this->assertEquals( array(), $status->errors, |
235 | 267 | "Creation of file at $source succeeded ($backendName)." ); |
236 | 268 | |
| 269 | + if ( isset( $op['overwrite'] ) || isset( $op['overwriteSame'] ) ) { |
| 270 | + $this->backend->copy( $op ); |
| 271 | + } |
| 272 | + |
237 | 273 | $status = $this->backend->doOperation( $op ); |
238 | 274 | $this->assertEquals( array(), $status->errors, |
239 | 275 | "Move from $source to $dest succeeded without warnings ($backendName)." ); |
— | — | @@ -271,13 +307,22 @@ |
272 | 308 | $dest, // dest |
273 | 309 | ); |
274 | 310 | |
275 | | - $op['overwrite'] = true; |
| 311 | + $op2 = $op; |
| 312 | + $op2['overwrite'] = true; |
276 | 313 | $cases[] = array( |
277 | | - $op, // operation |
| 314 | + $op2, // operation |
278 | 315 | $source, // source |
279 | 316 | $dest, // dest |
280 | 317 | ); |
281 | 318 | |
| 319 | + $op2 = $op; |
| 320 | + $op2['overwriteSame'] = true; |
| 321 | + $cases[] = array( |
| 322 | + $op2, // operation |
| 323 | + $source, // source |
| 324 | + $dest, // dest |
| 325 | + ); |
| 326 | + |
282 | 327 | return $cases; |
283 | 328 | } |
284 | 329 | |
— | — | @@ -304,7 +349,7 @@ |
305 | 350 | if ( $withSource ) { |
306 | 351 | $status = $this->backend->doOperation( |
307 | 352 | array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) ); |
308 | | - $this->assertEquals( true, $status->isOK(), |
| 353 | + $this->assertEquals( array(), $status->errors, |
309 | 354 | "Creation of file at $source succeeded ($backendName)." ); |
310 | 355 | } |
311 | 356 | |
— | — | @@ -388,7 +433,7 @@ |
389 | 434 | if ( $alreadyExists ) { |
390 | 435 | $status = $this->backend->doOperation( |
391 | 436 | array( 'op' => 'create', 'content' => $oldText, 'dst' => $dest ) ); |
392 | | - $this->assertEquals( true, $status->isOK(), |
| 437 | + $this->assertEquals( array(), $status->errors, |
393 | 438 | "Creation of file at $dest succeeded ($backendName)." ); |
394 | 439 | } |
395 | 440 | |
— | — | @@ -452,15 +497,26 @@ |
453 | 498 | strlen( $dummyText ) |
454 | 499 | ); |
455 | 500 | |
456 | | - $op['overwrite'] = true; |
| 501 | + $op2 = $op; |
| 502 | + $op2['overwrite'] = true; |
457 | 503 | $cases[] = array( |
458 | | - $op, // operation |
| 504 | + $op2, // operation |
459 | 505 | $source, // source |
460 | 506 | true, // dest already exists |
461 | 507 | true, // succeeds |
462 | 508 | strlen( $dummyText ) |
463 | 509 | ); |
464 | 510 | |
| 511 | + $op2 = $op; |
| 512 | + $op2['overwriteSame'] = true; |
| 513 | + $cases[] = array( |
| 514 | + $op2, // operation |
| 515 | + $source, // source |
| 516 | + true, // dest already exists |
| 517 | + false, // succeeds |
| 518 | + strlen( $dummyText ) |
| 519 | + ); |
| 520 | + |
465 | 521 | return $cases; |
466 | 522 | } |
467 | 523 | |
— | — | @@ -498,7 +554,7 @@ |
499 | 555 | } |
500 | 556 | $status = $this->backend->doOperations( $ops ); |
501 | 557 | |
502 | | - $this->assertEquals( true, $status->isOK(), |
| 558 | + $this->assertEquals( array(), $status->errors, |
503 | 559 | "Creation of source files succeeded ($backendName)." ); |
504 | 560 | |
505 | 561 | $dest = $params['dst']; |
— | — | @@ -664,7 +720,7 @@ |
665 | 721 | |
666 | 722 | $status = $this->backend->doOperation( |
667 | 723 | array( 'op' => 'create', 'content' => $content, 'dst' => $source ) ); |
668 | | - $this->assertEquals( true, $status->isOK(), |
| 724 | + $this->assertEquals( array(), $status->errors, |
669 | 725 | "Creation of file at $source succeeded ($backendName)." ); |
670 | 726 | |
671 | 727 | $tmpFile = $this->backend->getLocalCopy( array( 'src' => $source ) ); |
— | — | @@ -707,7 +763,7 @@ |
708 | 764 | |
709 | 765 | $status = $this->backend->doOperation( |
710 | 766 | array( 'op' => 'create', 'content' => $content, 'dst' => $source ) ); |
711 | | - $this->assertEquals( true, $status->isOK(), |
| 767 | + $this->assertEquals( array(), $status->errors, |
712 | 768 | "Creation of file at $source succeeded ($backendName)." ); |
713 | 769 | |
714 | 770 | $tmpFile = $this->backend->getLocalReference( array( 'src' => $source ) ); |
— | — | @@ -996,7 +1052,7 @@ |
997 | 1053 | $iter = $backend->getFileList( array( 'dir' => "$base/$container" ) ); |
998 | 1054 | if ( $iter ) { |
999 | 1055 | foreach ( $iter as $file ) { |
1000 | | - $backend->doOperation( array( 'op' => 'delete', 'src' => "$base/$container/$file" ) ); |
| 1056 | + $backend->delete( array( 'src' => "$base/$container/$file", 'ignoreMissingSource' => 1 ) ); |
1001 | 1057 | $tmp = $file; |
1002 | 1058 | while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) { |
1003 | 1059 | $backend->clean( array( 'dir' => $tmp ) ); |
Index: trunk/phase3/includes/filerepo/backend/SwiftFileBackend.php |
— | — | @@ -655,7 +655,7 @@ |
656 | 656 | */ |
657 | 657 | protected function getConnection() { |
658 | 658 | if ( $this->conn === false ) { |
659 | | - return false; // failed last attempt |
| 659 | + throw new InvalidResponseException; // failed last attempt |
660 | 660 | } |
661 | 661 | // Session keys expire after a while, so we renew them periodically |
662 | 662 | if ( $this->conn && ( time() - $this->connStarted ) > $this->authTTL ) { |
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -629,12 +629,14 @@ |
630 | 630 | * @return Status |
631 | 631 | */ |
632 | 632 | final public function createInternal( array $params ) { |
| 633 | + wfProfileIn( __METHOD__ ); |
633 | 634 | if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) { |
634 | 635 | $status = Status::newFatal( 'backend-fail-create', $params['dst'] ); |
635 | 636 | } else { |
636 | 637 | $status = $this->doCreateInternal( $params ); |
637 | 638 | $this->clearCache( array( $params['dst'] ) ); |
638 | 639 | } |
| 640 | + wfProfileOut( __METHOD__ ); |
639 | 641 | return $status; |
640 | 642 | } |
641 | 643 | |
— | — | @@ -656,12 +658,14 @@ |
657 | 659 | * @return Status |
658 | 660 | */ |
659 | 661 | final public function storeInternal( array $params ) { |
| 662 | + wfProfileIn( __METHOD__ ); |
660 | 663 | if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) { |
661 | 664 | $status = Status::newFatal( 'backend-fail-store', $params['dst'] ); |
662 | 665 | } else { |
663 | 666 | $status = $this->doStoreInternal( $params ); |
664 | 667 | $this->clearCache( array( $params['dst'] ) ); |
665 | 668 | } |
| 669 | + wfProfileOut( __METHOD__ ); |
666 | 670 | return $status; |
667 | 671 | } |
668 | 672 | |
— | — | @@ -683,8 +687,10 @@ |
684 | 688 | * @return Status |
685 | 689 | */ |
686 | 690 | final public function copyInternal( array $params ) { |
| 691 | + wfProfileIn( __METHOD__ ); |
687 | 692 | $status = $this->doCopyInternal( $params ); |
688 | 693 | $this->clearCache( array( $params['dst'] ) ); |
| 694 | + wfProfileOut( __METHOD__ ); |
689 | 695 | return $status; |
690 | 696 | } |
691 | 697 | |
— | — | @@ -705,8 +711,10 @@ |
706 | 712 | * @return Status |
707 | 713 | */ |
708 | 714 | final public function deleteInternal( array $params ) { |
| 715 | + wfProfileIn( __METHOD__ ); |
709 | 716 | $status = $this->doDeleteInternal( $params ); |
710 | 717 | $this->clearCache( array( $params['src'] ) ); |
| 718 | + wfProfileOut( __METHOD__ ); |
711 | 719 | return $status; |
712 | 720 | } |
713 | 721 | |
— | — | @@ -728,8 +736,10 @@ |
729 | 737 | * @return Status |
730 | 738 | */ |
731 | 739 | final public function moveInternal( array $params ) { |
| 740 | + wfProfileIn( __METHOD__ ); |
732 | 741 | $status = $this->doMoveInternal( $params ); |
733 | 742 | $this->clearCache( array( $params['src'], $params['dst'] ) ); |
| 743 | + wfProfileOut( __METHOD__ ); |
734 | 744 | return $status; |
735 | 745 | } |
736 | 746 | |
— | — | @@ -739,12 +749,11 @@ |
740 | 750 | protected function doMoveInternal( array $params ) { |
741 | 751 | // Copy source to dest |
742 | 752 | $status = $this->copyInternal( $params ); |
743 | | - if ( !$status->isOK() ) { |
744 | | - return $status; |
| 753 | + if ( $status->isOK() ) { |
| 754 | + // Delete source (only fails due to races or medium going down) |
| 755 | + $status->merge( $this->deleteInternal( array( 'src' => $params['src'] ) ) ); |
| 756 | + $status->setResult( true, $status->value ); // ignore delete() errors |
745 | 757 | } |
746 | | - // Delete source (only fails due to races or medium going down) |
747 | | - $status->merge( $this->deleteInternal( array( 'src' => $params['src'] ) ) ); |
748 | | - $status->setResult( true, $status->value ); // ignore delete() errors |
749 | 758 | return $status; |
750 | 759 | } |
751 | 760 | |
— | — | @@ -752,17 +761,17 @@ |
753 | 762 | * @see FileBackendBase::concatenate() |
754 | 763 | */ |
755 | 764 | final public function concatenate( array $params ) { |
| 765 | + wfProfileIn( __METHOD__ ); |
756 | 766 | $status = Status::newGood(); |
757 | 767 | |
758 | 768 | // Try to lock the source files for the scope of this function |
759 | 769 | $scopeLockS = $this->getScopedFileLocks( $params['srcs'], LockManager::LOCK_UW, $status ); |
760 | | - if ( !$status->isOK() ) { |
761 | | - return $status; // abort |
| 770 | + if ( $status->isOK() ) { |
| 771 | + // Actually do the concatenation |
| 772 | + $status->merge( $this->doConcatenate( $params ) ); |
762 | 773 | } |
763 | 774 | |
764 | | - // Actually do the concatenation |
765 | | - $status->merge( $this->doConcatenate( $params ) ); |
766 | | - |
| 775 | + wfProfileOut( __METHOD__ ); |
767 | 776 | return $status; |
768 | 777 | } |
769 | 778 | |
— | — | @@ -825,12 +834,16 @@ |
826 | 835 | * @see FileBackendBase::doPrepare() |
827 | 836 | */ |
828 | 837 | final protected function doPrepare( array $params ) { |
| 838 | + wfProfileIn( __METHOD__ ); |
| 839 | + |
829 | 840 | $status = Status::newGood(); |
830 | 841 | list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); |
831 | 842 | if ( $dir === null ) { |
832 | 843 | $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); |
| 844 | + wfProfileOut( __METHOD__ ); |
833 | 845 | return $status; // invalid storage path |
834 | 846 | } |
| 847 | + |
835 | 848 | if ( $shard !== null ) { // confined to a single container/shard |
836 | 849 | $status->merge( $this->doPrepareInternal( $fullCont, $dir, $params ) ); |
837 | 850 | } else { // directory is on several shards |
— | — | @@ -840,6 +853,8 @@ |
841 | 854 | $status->merge( $this->doPrepareInternal( "{$fullCont}{$suffix}", $dir, $params ) ); |
842 | 855 | } |
843 | 856 | } |
| 857 | + |
| 858 | + wfProfileOut( __METHOD__ ); |
844 | 859 | return $status; |
845 | 860 | } |
846 | 861 | |
— | — | @@ -854,12 +869,16 @@ |
855 | 870 | * @see FileBackendBase::doSecure() |
856 | 871 | */ |
857 | 872 | final protected function doSecure( array $params ) { |
| 873 | + wfProfileIn( __METHOD__ ); |
858 | 874 | $status = Status::newGood(); |
| 875 | + |
859 | 876 | list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); |
860 | 877 | if ( $dir === null ) { |
861 | 878 | $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); |
| 879 | + wfProfileOut( __METHOD__ ); |
862 | 880 | return $status; // invalid storage path |
863 | 881 | } |
| 882 | + |
864 | 883 | if ( $shard !== null ) { // confined to a single container/shard |
865 | 884 | $status->merge( $this->doSecureInternal( $fullCont, $dir, $params ) ); |
866 | 885 | } else { // directory is on several shards |
— | — | @@ -869,6 +888,8 @@ |
870 | 889 | $status->merge( $this->doSecureInternal( "{$fullCont}{$suffix}", $dir, $params ) ); |
871 | 890 | } |
872 | 891 | } |
| 892 | + |
| 893 | + wfProfileOut( __METHOD__ ); |
873 | 894 | return $status; |
874 | 895 | } |
875 | 896 | |
— | — | @@ -883,18 +904,24 @@ |
884 | 905 | * @see FileBackendBase::doClean() |
885 | 906 | */ |
886 | 907 | final protected function doClean( array $params ) { |
| 908 | + wfProfileIn( __METHOD__ ); |
887 | 909 | $status = Status::newGood(); |
| 910 | + |
888 | 911 | list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); |
889 | 912 | if ( $dir === null ) { |
890 | 913 | $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); |
| 914 | + wfProfileOut( __METHOD__ ); |
891 | 915 | return $status; // invalid storage path |
892 | 916 | } |
| 917 | + |
893 | 918 | // Attempt to lock this directory... |
894 | 919 | $filesLockEx = array( $params['dir'] ); |
895 | 920 | $scopedLockE = $this->getScopedFileLocks( $filesLockEx, LockManager::LOCK_EX, $status ); |
896 | 921 | if ( !$status->isOK() ) { |
| 922 | + wfProfileOut( __METHOD__ ); |
897 | 923 | return $status; // abort |
898 | 924 | } |
| 925 | + |
899 | 926 | if ( $shard !== null ) { // confined to a single container/shard |
900 | 927 | $status->merge( $this->doCleanInternal( $fullCont, $dir, $params ) ); |
901 | 928 | } else { // directory is on several shards |
— | — | @@ -904,6 +931,8 @@ |
905 | 932 | $status->merge( $this->doCleanInternal( "{$fullCont}{$suffix}", $dir, $params ) ); |
906 | 933 | } |
907 | 934 | } |
| 935 | + |
| 936 | + wfProfileOut( __METHOD__ ); |
908 | 937 | return $status; |
909 | 938 | } |
910 | 939 | |
— | — | @@ -918,47 +947,44 @@ |
919 | 948 | * @see FileBackendBase::fileExists() |
920 | 949 | */ |
921 | 950 | final public function fileExists( array $params ) { |
| 951 | + wfProfileIn( __METHOD__ ); |
922 | 952 | $stat = $this->getFileStat( $params ); |
923 | | - if ( $stat === null ) { |
924 | | - return null; // failure |
925 | | - } |
926 | | - return (bool)$stat; |
| 953 | + wfProfileOut( __METHOD__ ); |
| 954 | + return ( $stat === null ) ? null : (bool)$stat; // null => failure |
927 | 955 | } |
928 | 956 | |
929 | 957 | /** |
930 | 958 | * @see FileBackendBase::getFileTimestamp() |
931 | 959 | */ |
932 | 960 | final public function getFileTimestamp( array $params ) { |
| 961 | + wfProfileIn( __METHOD__ ); |
933 | 962 | $stat = $this->getFileStat( $params ); |
934 | | - if ( $stat ) { |
935 | | - return $stat['mtime']; |
936 | | - } else { |
937 | | - return false; |
938 | | - } |
| 963 | + wfProfileOut( __METHOD__ ); |
| 964 | + return $stat ? $stat['mtime'] : false; |
939 | 965 | } |
940 | 966 | |
941 | 967 | /** |
942 | 968 | * @see FileBackendBase::getFileSize() |
943 | 969 | */ |
944 | 970 | final public function getFileSize( array $params ) { |
| 971 | + wfProfileIn( __METHOD__ ); |
945 | 972 | $stat = $this->getFileStat( $params ); |
946 | | - if ( $stat ) { |
947 | | - return $stat['size']; |
948 | | - } else { |
949 | | - return false; |
950 | | - } |
| 973 | + wfProfileOut( __METHOD__ ); |
| 974 | + return $stat ? $stat['size'] : false; |
951 | 975 | } |
952 | 976 | |
953 | 977 | /** |
954 | 978 | * @see FileBackendBase::getFileStat() |
955 | 979 | */ |
956 | 980 | final public function getFileStat( array $params ) { |
| 981 | + wfProfileIn( __METHOD__ ); |
957 | 982 | $path = $params['src']; |
958 | 983 | $latest = !empty( $params['latest'] ); |
959 | 984 | if ( isset( $this->cache[$path]['stat'] ) ) { |
960 | 985 | // If we want the latest data, check that this cached |
961 | 986 | // value was in fact fetched with the latest available data. |
962 | 987 | if ( !$latest || $this->cache[$path]['stat']['latest'] ) { |
| 988 | + wfProfileOut( __METHOD__ ); |
963 | 989 | return $this->cache[$path]['stat']; |
964 | 990 | } |
965 | 991 | } |
— | — | @@ -968,6 +994,7 @@ |
969 | 995 | $this->cache[$path]['stat'] = $stat; |
970 | 996 | $this->cache[$path]['stat']['latest'] = $latest; |
971 | 997 | } |
| 998 | + wfProfileOut( __METHOD__ ); |
972 | 999 | return $stat; |
973 | 1000 | } |
974 | 1001 | |
— | — | @@ -980,13 +1007,16 @@ |
981 | 1008 | * @see FileBackendBase::getFileContents() |
982 | 1009 | */ |
983 | 1010 | public function getFileContents( array $params ) { |
| 1011 | + wfProfileIn( __METHOD__ ); |
984 | 1012 | $tmpFile = $this->getLocalReference( $params ); |
985 | 1013 | if ( !$tmpFile ) { |
| 1014 | + wfProfileOut( __METHOD__ ); |
986 | 1015 | return false; |
987 | 1016 | } |
988 | 1017 | wfSuppressWarnings(); |
989 | 1018 | $data = file_get_contents( $tmpFile->getPath() ); |
990 | 1019 | wfRestoreWarnings(); |
| 1020 | + wfProfileOut( __METHOD__ ); |
991 | 1021 | return $data; |
992 | 1022 | } |
993 | 1023 | |
— | — | @@ -994,8 +1024,10 @@ |
995 | 1025 | * @see FileBackendBase::getFileSha1Base36() |
996 | 1026 | */ |
997 | 1027 | final public function getFileSha1Base36( array $params ) { |
| 1028 | + wfProfileIn( __METHOD__ ); |
998 | 1029 | $path = $params['src']; |
999 | 1030 | if ( isset( $this->cache[$path]['sha1'] ) ) { |
| 1031 | + wfProfileOut( __METHOD__ ); |
1000 | 1032 | return $this->cache[$path]['sha1']; |
1001 | 1033 | } |
1002 | 1034 | $hash = $this->doGetFileSha1Base36( $params ); |
— | — | @@ -1003,6 +1035,7 @@ |
1004 | 1036 | $this->trimCache(); // limit memory |
1005 | 1037 | $this->cache[$path]['sha1'] = $hash; |
1006 | 1038 | } |
| 1039 | + wfProfileOut( __METHOD__ ); |
1007 | 1040 | return $hash; |
1008 | 1041 | } |
1009 | 1042 | |
— | — | @@ -1021,21 +1054,22 @@ |
1022 | 1055 | /** |
1023 | 1056 | * @see FileBackendBase::getFileProps() |
1024 | 1057 | */ |
1025 | | - public function getFileProps( array $params ) { |
| 1058 | + final public function getFileProps( array $params ) { |
| 1059 | + wfProfileIn( __METHOD__ ); |
1026 | 1060 | $fsFile = $this->getLocalReference( $params ); |
1027 | | - if ( !$fsFile ) { |
1028 | | - return FSFile::placeholderProps(); |
1029 | | - } else { |
1030 | | - return $fsFile->getProps(); |
1031 | | - } |
| 1061 | + $props = $fsFile ? $fsFile->getProps() : FSFile::placeholderProps(); |
| 1062 | + wfProfileOut( __METHOD__ ); |
| 1063 | + return $props; |
1032 | 1064 | } |
1033 | 1065 | |
1034 | 1066 | /** |
1035 | 1067 | * @see FileBackendBase::getLocalReference() |
1036 | 1068 | */ |
1037 | 1069 | public function getLocalReference( array $params ) { |
| 1070 | + wfProfileIn( __METHOD__ ); |
1038 | 1071 | $path = $params['src']; |
1039 | 1072 | if ( isset( $this->cache[$path]['localRef'] ) ) { |
| 1073 | + wfProfileOut( __METHOD__ ); |
1040 | 1074 | return $this->cache[$path]['localRef']; |
1041 | 1075 | } |
1042 | 1076 | $tmpFile = $this->getLocalCopy( $params ); |
— | — | @@ -1043,6 +1077,7 @@ |
1044 | 1078 | $this->trimCache(); // limit memory |
1045 | 1079 | $this->cache[$path]['localRef'] = $tmpFile; |
1046 | 1080 | } |
| 1081 | + wfProfileOut( __METHOD__ ); |
1047 | 1082 | return $tmpFile; |
1048 | 1083 | } |
1049 | 1084 | |
— | — | @@ -1050,6 +1085,7 @@ |
1051 | 1086 | * @see FileBackendBase::streamFile() |
1052 | 1087 | */ |
1053 | 1088 | final public function streamFile( array $params ) { |
| 1089 | + wfProfileIn( __METHOD__ ); |
1054 | 1090 | $status = Status::newGood(); |
1055 | 1091 | |
1056 | 1092 | $info = $this->getFileStat( $params ); |
— | — | @@ -1068,6 +1104,7 @@ |
1069 | 1105 | $status->fatal( 'backend-fail-stream', $params['src'] ); |
1070 | 1106 | } |
1071 | 1107 | |
| 1108 | + wfProfileOut( __METHOD__ ); |
1072 | 1109 | return $status; |
1073 | 1110 | } |
1074 | 1111 | |
— | — | @@ -1169,6 +1206,7 @@ |
1170 | 1207 | * @see FileBackendBase::doOperationsInternal() |
1171 | 1208 | */ |
1172 | 1209 | protected function doOperationsInternal( array $ops, array $opts ) { |
| 1210 | + wfProfileIn( __METHOD__ ); |
1173 | 1211 | $status = Status::newGood(); |
1174 | 1212 | |
1175 | 1213 | // Build up a list of FileOps... |
— | — | @@ -1190,6 +1228,7 @@ |
1191 | 1229 | $scopeLockS = $this->getScopedFileLocks( $filesLockSh, LockManager::LOCK_UW, $status ); |
1192 | 1230 | $scopeLockE = $this->getScopedFileLocks( $filesLockEx, LockManager::LOCK_EX, $status ); |
1193 | 1231 | if ( !$status->isOK() ) { |
| 1232 | + wfProfileOut( __METHOD__ ); |
1194 | 1233 | return $status; // abort |
1195 | 1234 | } |
1196 | 1235 | } |
— | — | @@ -1204,6 +1243,7 @@ |
1205 | 1244 | $status->merge( $subStatus ); |
1206 | 1245 | $status->success = $subStatus->success; // not done in merge() |
1207 | 1246 | |
| 1247 | + wfProfileOut( __METHOD__ ); |
1208 | 1248 | return $status; |
1209 | 1249 | } |
1210 | 1250 | |