Merge "Add wgRevisionId variable to ResourceLoader"
[lhc/web/wiklou.git] / includes / externalstore / ExternalStoreMwstore.php
index 8e0adda..aa48679 100644 (file)
@@ -46,6 +46,29 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
                return false;
        }
 
+       /**
+        * Fetch data from given external store URLs.
+        * The URL returned is of the form of the form mwstore://backend/container/wiki/id
+        *
+        * @param array $urls An array of external store URLs
+        * @return array A map from url to stored content. Failed results are not represented.
+        */
+       public function batchFetchFromURLs( array $urls ) {
+               $pathsByBackend = array();
+               foreach ( $urls as $url ) {
+                       $be = FileBackendGroup::singleton()->backendFromPath( $url );
+                       if ( $be instanceof FileBackend ) {
+                               $pathsByBackend[$be->getName()][] = $url;
+                       }
+               }
+               $blobs = array();
+               foreach ( $pathsByBackend as $backendName => $paths ) {
+                       $be = FileBackendGroup::get( $backendName );
+                       $blobs = $blobs + $be->getFileContentsMulti( array( 'srcs' => $paths ) );
+               }
+               return $blobs;
+       }
+
        /**
         * @see ExternalStoreMedium::store()
         */
@@ -62,7 +85,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
                        $url = $be->getContainerStoragePath( 'data' ) . '/' .
                                rawurlencode( $wiki ) . "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}";
 
-                       $be->prepare( array( 'dir' => dirname( $url ) ) );
+                       $be->prepare( array( 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ) );
                        if ( $be->create( array( 'dst' => $url, 'content' => $data ) )->isOK() ) {
                                return $url;
                        }