X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexternalstore%2FExternalStoreMwstore.php;h=0c6d022fc5da142752af3fd86954ff9e408fa965;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hp=c3c5dcb79a3792da9e7d41b8f7b117735036988c;hpb=174f34a86de3162bc673fd3bc6bed815cccf0edc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/externalstore/ExternalStoreMwstore.php b/includes/externalstore/ExternalStoreMwstore.php index c3c5dcb79a..0c6d022fc5 100644 --- a/includes/externalstore/ExternalStoreMwstore.php +++ b/includes/externalstore/ExternalStoreMwstore.php @@ -35,13 +35,15 @@ class ExternalStoreMwstore extends ExternalStoreMedium { * The URL returned is of the form of the form mwstore://backend/container/wiki/id * * @see ExternalStoreMedium::fetchFromURL() + * @param string $url + * @return bool */ public function fetchFromURL( $url ) { $be = FileBackendGroup::singleton()->backendFromPath( $url ); if ( $be instanceof FileBackend ) { // We don't need "latest" since objects are immutable and // backends should at least have "read-after-create" consistency. - return $be->getFileContents( array( 'src' => $url ) ); + return $be->getFileContents( [ 'src' => $url ] ); } return false; @@ -55,25 +57,22 @@ class ExternalStoreMwstore extends ExternalStoreMedium { * @return array A map from url to stored content. Failed results are not represented. */ public function batchFetchFromURLs( array $urls ) { - $pathsByBackend = array(); + $pathsByBackend = []; foreach ( $urls as $url ) { $be = FileBackendGroup::singleton()->backendFromPath( $url ); if ( $be instanceof FileBackend ) { $pathsByBackend[$be->getName()][] = $url; } } - $blobs = array(); + $blobs = []; foreach ( $pathsByBackend as $backendName => $paths ) { $be = FileBackendGroup::singleton()->get( $backendName ); - $blobs = $blobs + $be->getFileContentsMulti( array( 'srcs' => $paths ) ); + $blobs = $blobs + $be->getFileContentsMulti( [ 'srcs' => $paths ] ); } return $blobs; } - /** - * @see ExternalStoreMedium::store() - */ public function store( $backend, $data ) { $be = FileBackendGroup::singleton()->get( $backend ); if ( $be instanceof FileBackend ) { @@ -89,12 +88,18 @@ class ExternalStoreMwstore extends ExternalStoreMedium { ? "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}" // keep directories small : "/{$rand[0]}/{$rand[1]}/{$id}"; // container sharding is only 2-levels - $be->prepare( array( 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ) ); - if ( $be->create( array( 'dst' => $url, 'content' => $data ) )->isOK() ) { + $be->prepare( [ 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ] ); + if ( $be->create( [ 'dst' => $url, 'content' => $data ] )->isOK() ) { return $url; } } return false; } + + public function isReadOnly( $backend ) { + $be = FileBackendGroup::singleton()->get( $backend ); + + return $be ? $be->isReadOnly() : false; + } }