Index: trunk/phase3/includes/filerepo/backend/FSFileBackend.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * Class for a file system (FS) based file backend. |
| 10 | + * @brief Class for a file system (FS) based file backend. |
11 | 11 | * |
12 | 12 | * All "containers" each map to a directory under the backend's base directory. |
13 | 13 | * For backwards-compatibility, some container paths can be set to custom paths. |
— | — | @@ -579,6 +579,10 @@ |
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
| 583 | + /** |
| 584 | + * @see Iterator::current() |
| 585 | + * @return string|bool String or false |
| 586 | + */ |
583 | 587 | public function current() { |
584 | 588 | // Return only the relative path and normalize slashes to FileBackend-style |
585 | 589 | // Make sure to use the realpath since the suffix is based upon that |
— | — | @@ -586,10 +590,18 @@ |
587 | 591 | substr( realpath( $this->iter->current() ), $this->suffixStart ) ); |
588 | 592 | } |
589 | 593 | |
| 594 | + /** |
| 595 | + * @see Iterator::key() |
| 596 | + * @return integer |
| 597 | + */ |
590 | 598 | public function key() { |
591 | 599 | return $this->pos; |
592 | 600 | } |
593 | 601 | |
| 602 | + /** |
| 603 | + * @see Iterator::next() |
| 604 | + * @return void |
| 605 | + */ |
594 | 606 | public function next() { |
595 | 607 | try { |
596 | 608 | $this->iter->next(); |
— | — | @@ -599,6 +611,10 @@ |
600 | 612 | ++$this->pos; |
601 | 613 | } |
602 | 614 | |
| 615 | + /** |
| 616 | + * @see Iterator::rewind() |
| 617 | + * @return void |
| 618 | + */ |
603 | 619 | public function rewind() { |
604 | 620 | $this->pos = 0; |
605 | 621 | try { |
— | — | @@ -608,6 +624,10 @@ |
609 | 625 | } |
610 | 626 | } |
611 | 627 | |
| 628 | + /** |
| 629 | + * @see Iterator::valid() |
| 630 | + * @return bool |
| 631 | + */ |
612 | 632 | public function valid() { |
613 | 633 | return $this->iter && $this->iter->valid(); |
614 | 634 | } |
Index: trunk/phase3/includes/filerepo/backend/FileBackendStore.php |
— | — | @@ -997,6 +997,10 @@ |
998 | 998 | $this->params = $params; |
999 | 999 | } |
1000 | 1000 | |
| 1001 | + /** |
| 1002 | + * @see Iterator::current() |
| 1003 | + * @return string|bool String or false |
| 1004 | + */ |
1001 | 1005 | public function current() { |
1002 | 1006 | if ( is_array( $this->iter ) ) { |
1003 | 1007 | return current( $this->iter ); |
— | — | @@ -1005,10 +1009,18 @@ |
1006 | 1010 | } |
1007 | 1011 | } |
1008 | 1012 | |
| 1013 | + /** |
| 1014 | + * @see Iterator::key() |
| 1015 | + * @return integer |
| 1016 | + */ |
1009 | 1017 | public function key() { |
1010 | 1018 | return $this->pos; |
1011 | 1019 | } |
1012 | 1020 | |
| 1021 | + /** |
| 1022 | + * @see Iterator::next() |
| 1023 | + * @return void |
| 1024 | + */ |
1013 | 1025 | public function next() { |
1014 | 1026 | ++$this->pos; |
1015 | 1027 | if ( is_array( $this->iter ) ) { |
— | — | @@ -1021,25 +1033,9 @@ |
1022 | 1034 | } |
1023 | 1035 | |
1024 | 1036 | /** |
1025 | | - * If the iterator for this container shard is out of items, |
1026 | | - * then move on to the next container that has items. |
1027 | | - * If there are none, then it advances to the last container. |
| 1037 | + * @see Iterator::rewind() |
| 1038 | + * @return void |
1028 | 1039 | */ |
1029 | | - protected function nextShardIteratorIfNotValid() { |
1030 | | - while ( !$this->valid() ) { |
1031 | | - if ( ++$this->curShard >= count( $this->shardSuffixes ) ) { |
1032 | | - break; // no more container shards |
1033 | | - } |
1034 | | - $this->setIteratorFromCurrentShard(); |
1035 | | - } |
1036 | | - } |
1037 | | - |
1038 | | - protected function setIteratorFromCurrentShard() { |
1039 | | - $suffix = $this->shardSuffixes[$this->curShard]; |
1040 | | - $this->iter = $this->backend->getFileListInternal( |
1041 | | - "{$this->container}{$suffix}", $this->directory, $this->params ); |
1042 | | - } |
1043 | | - |
1044 | 1040 | public function rewind() { |
1045 | 1041 | $this->pos = 0; |
1046 | 1042 | $this->curShard = 0; |
— | — | @@ -1048,6 +1044,10 @@ |
1049 | 1045 | $this->nextShardIteratorIfNotValid(); |
1050 | 1046 | } |
1051 | 1047 | |
| 1048 | + /** |
| 1049 | + * @see Iterator::valid() |
| 1050 | + * @return bool |
| 1051 | + */ |
1052 | 1052 | public function valid() { |
1053 | 1053 | if ( $this->iter == null ) { |
1054 | 1054 | return false; // some failure? |
— | — | @@ -1057,4 +1057,27 @@ |
1058 | 1058 | return $this->iter->valid(); |
1059 | 1059 | } |
1060 | 1060 | } |
| 1061 | + |
| 1062 | + /** |
| 1063 | + * If the list iterator for this container shard is out of items, |
| 1064 | + * then move on to the next container that has items. |
| 1065 | + * If there are none, then it advances to the last container. |
| 1066 | + */ |
| 1067 | + protected function nextShardIteratorIfNotValid() { |
| 1068 | + while ( !$this->valid() ) { |
| 1069 | + if ( ++$this->curShard >= count( $this->shardSuffixes ) ) { |
| 1070 | + break; // no more container shards |
| 1071 | + } |
| 1072 | + $this->setIteratorFromCurrentShard(); |
| 1073 | + } |
| 1074 | + } |
| 1075 | + |
| 1076 | + /** |
| 1077 | + * Set the list iterator to that of the current container shard |
| 1078 | + */ |
| 1079 | + protected function setIteratorFromCurrentShard() { |
| 1080 | + $suffix = $this->shardSuffixes[$this->curShard]; |
| 1081 | + $this->iter = $this->backend->getFileListInternal( |
| 1082 | + "{$this->container}{$suffix}", $this->directory, $this->params ); |
| 1083 | + } |
1061 | 1084 | } |
Index: trunk/phase3/includes/filerepo/backend/SwiftFileBackend.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** |
11 | | - * Class for an OpenStack Swift based file backend. |
| 11 | + * @brief Class for an OpenStack Swift based file backend. |
12 | 12 | * |
13 | 13 | * This requires the SwiftCloudFiles MediaWiki extension, which includes |
14 | 14 | * the php-cloudfiles library (https://github.com/rackspace/php-cloudfiles). |
— | — | @@ -856,14 +856,26 @@ |
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
| 860 | + /** |
| 861 | + * @see Iterator::current() |
| 862 | + * @return string|bool String or false |
| 863 | + */ |
860 | 864 | public function current() { |
861 | 865 | return substr( current( $this->bufferIter ), $this->suffixStart ); |
862 | 866 | } |
863 | 867 | |
| 868 | + /** |
| 869 | + * @see Iterator::key() |
| 870 | + * @return integer |
| 871 | + */ |
864 | 872 | public function key() { |
865 | 873 | return $this->pos; |
866 | 874 | } |
867 | 875 | |
| 876 | + /** |
| 877 | + * @see Iterator::next() |
| 878 | + * @return void |
| 879 | + */ |
868 | 880 | public function next() { |
869 | 881 | // Advance to the next file in the page |
870 | 882 | next( $this->bufferIter ); |
— | — | @@ -878,6 +890,10 @@ |
879 | 891 | } |
880 | 892 | } |
881 | 893 | |
| 894 | + /** |
| 895 | + * @see Iterator::rewind() |
| 896 | + * @return void |
| 897 | + */ |
882 | 898 | public function rewind() { |
883 | 899 | $this->pos = 0; |
884 | 900 | $this->bufferAfter = null; |
— | — | @@ -886,6 +902,10 @@ |
887 | 903 | ); |
888 | 904 | } |
889 | 905 | |
| 906 | + /** |
| 907 | + * @see Iterator::valid() |
| 908 | + * @return bool |
| 909 | + */ |
890 | 910 | public function valid() { |
891 | 911 | return ( current( $this->bufferIter ) !== false ); // no paths can have this value |
892 | 912 | } |
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | */ |
16 | 16 | |
17 | 17 | /** |
18 | | - * Base class for all file backend classes (including multi-write backends). |
| 18 | + * @brief Base class for all file backend classes (including multi-write backends). |
19 | 19 | * |
20 | 20 | * This class defines the methods as abstract that subclasses must implement. |
21 | 21 | * Outside callers can assume that all backends will have these functions. |
— | — | @@ -658,6 +658,31 @@ |
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
| 662 | + * Get the parent storage directory of a storage path. |
| 663 | + * This returns a path like "mwstore://backend/container", |
| 664 | + * "mwstore://backend/container/...", or null if there is no parent. |
| 665 | + * |
| 666 | + * @param $storagePath string |
| 667 | + * @return string|null |
| 668 | + */ |
| 669 | + final public static function parentStoragePath( $storagePath ) { |
| 670 | + $storagePath = dirname( $storagePath ); |
| 671 | + list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath ); |
| 672 | + return ( $rel === null ) ? null : $storagePath; |
| 673 | + } |
| 674 | + |
| 675 | + /** |
| 676 | + * Get the final extension from a storage or FS path |
| 677 | + * |
| 678 | + * @param $path string |
| 679 | + * @return string |
| 680 | + */ |
| 681 | + final public static function extensionFromPath( $path ) { |
| 682 | + $i = strrpos( $path, '.' ); |
| 683 | + return strtolower( $i ? substr( $path, $i + 1 ) : '' ); |
| 684 | + } |
| 685 | + |
| 686 | + /** |
662 | 687 | * Validate and normalize a relative storage path. |
663 | 688 | * Null is returned if the path involves directory traversal. |
664 | 689 | * Traversal is insecure for FS backends and broken for others. |
— | — | @@ -687,29 +712,4 @@ |
688 | 713 | } |
689 | 714 | return $path; |
690 | 715 | } |
691 | | - |
692 | | - /** |
693 | | - * Get the parent storage directory of a storage path. |
694 | | - * This returns a path like "mwstore://backend/container", |
695 | | - * "mwstore://backend/container/...", or null if there is no parent. |
696 | | - * |
697 | | - * @param $storagePath string |
698 | | - * @return string|null |
699 | | - */ |
700 | | - final public static function parentStoragePath( $storagePath ) { |
701 | | - $storagePath = dirname( $storagePath ); |
702 | | - list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath ); |
703 | | - return ( $rel === null ) ? null : $storagePath; |
704 | | - } |
705 | | - |
706 | | - /** |
707 | | - * Get the final extension from a storage or FS path |
708 | | - * |
709 | | - * @param $path string |
710 | | - * @return string |
711 | | - */ |
712 | | - final public static function extensionFromPath( $path ) { |
713 | | - $i = strrpos( $path, '.' ); |
714 | | - return strtolower( $i ? substr( $path, $i + 1 ) : '' ); |
715 | | - } |
716 | 716 | } |
Index: trunk/phase3/includes/filerepo/backend/lockmanager/FSLockManager.php |
— | — | @@ -38,6 +38,10 @@ |
39 | 39 | $this->lockDir = $config['lockDirectory']; |
40 | 40 | } |
41 | 41 | |
| 42 | + /** |
| 43 | + * @see LockManager::doLock() |
| 44 | + * @return Status |
| 45 | + */ |
42 | 46 | protected function doLock( array $paths, $type ) { |
43 | 47 | $status = Status::newGood(); |
44 | 48 | |
— | — | @@ -56,6 +60,10 @@ |
57 | 61 | return $status; |
58 | 62 | } |
59 | 63 | |
| 64 | + /** |
| 65 | + * @see LockManager::doUnlock() |
| 66 | + * @return Status |
| 67 | + */ |
60 | 68 | protected function doUnlock( array $paths, $type ) { |
61 | 69 | $status = Status::newGood(); |
62 | 70 | |
Index: trunk/phase3/includes/filerepo/backend/lockmanager/LSLockManager.php |
— | — | @@ -68,6 +68,10 @@ |
69 | 69 | $this->session = wfBaseConvert( sha1( $this->session ), 16, 36, 31 ); |
70 | 70 | } |
71 | 71 | |
| 72 | + /** |
| 73 | + * @see LockManager::doLock() |
| 74 | + * @return Status |
| 75 | + */ |
72 | 76 | protected function doLock( array $paths, $type ) { |
73 | 77 | $status = Status::newGood(); |
74 | 78 | |
— | — | @@ -117,6 +121,10 @@ |
118 | 122 | return $status; |
119 | 123 | } |
120 | 124 | |
| 125 | + /** |
| 126 | + * @see LockManager::doUnlock() |
| 127 | + * @return Status |
| 128 | + */ |
121 | 129 | protected function doUnlock( array $paths, $type ) { |
122 | 130 | $status = Status::newGood(); |
123 | 131 | |
Index: trunk/phase3/includes/filerepo/backend/lockmanager/LockManager.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** |
15 | | - * Class for handling resource locking. |
| 15 | + * @brief Class for handling resource locking. |
16 | 16 | * |
17 | 17 | * Locks on resource keys can either be shared or exclusive. |
18 | 18 | * |
— | — | @@ -178,10 +178,18 @@ |
179 | 179 | * @since 1.19 |
180 | 180 | */ |
181 | 181 | class NullLockManager extends LockManager { |
| 182 | + /** |
| 183 | + * @see LockManager::doLock() |
| 184 | + * @return Status |
| 185 | + */ |
182 | 186 | protected function doLock( array $paths, $type ) { |
183 | 187 | return Status::newGood(); |
184 | 188 | } |
185 | 189 | |
| 190 | + /** |
| 191 | + * @see LockManager::doUnlock() |
| 192 | + * @return Status |
| 193 | + */ |
186 | 194 | protected function doUnlock( array $paths, $type ) { |
187 | 195 | return Status::newGood(); |
188 | 196 | } |