Merge "add Article::setParserOptions" into Wikidata
[lhc/web/wiklou.git] / includes / filerepo / backend / SwiftFileBackend.php
index 4420c22..3063440 100644 (file)
@@ -56,25 +56,25 @@ class SwiftFileBackend extends FileBackendStore {
        /**
         * @see FileBackendStore::__construct()
         * Additional $config params include:
-        *    swiftAuthUrl       : Swift authentication server URL
-        *    swiftUser          : Swift user used by MediaWiki (account:username)
-        *    swiftKey           : Swift authentication key for the above user
-        *    swiftAuthTTL       : Swift authentication TTL (seconds)
-        *    swiftAnonUser      : Swift user used for end-user requests (account:username).
-        *                         If set, then views of public containers are assumed to go
-        *                         through this user. If not set, then public containers are
-        *                         accessible to unauthenticated requests via ".r:*" in the ACL.
-        *    swiftUseCDN        : Whether a Cloud Files Content Delivery Network is set up
-        *    swiftCDNExpiry     : How long (in seconds) to store content in the CDN.
-        *                         If files may likely change, this should probably not exceed
-        *                         a few days. For example, deletions may take this long to apply.
-        *                         If object purging is enabled, however, this is not an issue.
-        *    swiftCDNPurgable   : Whether object purge requests are allowed by the CDN.
-        *    shardViaHashLevels : Map of container names to sharding config with:
-        *                         'base'   : base of hash characters, 16 or 36
-        *                         'levels' : the number of hash levels (and digits)
-        *                         'repeat' : hash subdirectories are prefixed with all the
-        *                                    parent hash directory names (e.g. "a/ab/abc")
+        *   - swiftAuthUrl       : Swift authentication server URL
+        *   - swiftUser          : Swift user used by MediaWiki (account:username)
+        *   - swiftKey           : Swift authentication key for the above user
+        *   - swiftAuthTTL       : Swift authentication TTL (seconds)
+        *   - swiftAnonUser      : Swift user used for end-user requests (account:username).
+        *                          If set, then views of public containers are assumed to go
+        *                          through this user. If not set, then public containers are
+        *                          accessible to unauthenticated requests via ".r:*" in the ACL.
+        *   - swiftUseCDN        : Whether a Cloud Files Content Delivery Network is set up
+        *   - swiftCDNExpiry     : How long (in seconds) to store content in the CDN.
+        *                          If files may likely change, this should probably not exceed
+        *                          a few days. For example, deletions may take this long to apply.
+        *                          If object purging is enabled, however, this is not an issue.
+        *   - swiftCDNPurgable   : Whether object purge requests are allowed by the CDN.
+        *   - shardViaHashLevels : Map of container names to sharding config with:
+        *                             - base   : base of hash characters, 16 or 36
+        *                             - levels : the number of hash levels (and digits)
+        *                             - repeat : hash subdirectories are prefixed with all the
+        *                                        parent hash directory names (e.g. "a/ab/abc")
         */
        public function __construct( array $config ) {
                parent::__construct( $config );
@@ -188,6 +188,9 @@ class SwiftFileBackend extends FileBackendStore {
                        $obj->set_etag( md5( $params['content'] ) );
                        // Use the same content type as StreamFile for security
                        $obj->content_type = StreamFile::contentTypeFromPath( $params['dst'] );
+                       if ( !strlen( $obj->content_type ) ) { // special case
+                               $obj->content_type = 'unknown/unknown';
+                       }
                        if ( !empty( $params['async'] ) ) { // deferred
                                $handle = $obj->write_async( $params['content'] );
                                $status->value = new SwiftFileOpHandle( $this, $params, 'Create', $handle );
@@ -267,6 +270,9 @@ class SwiftFileBackend extends FileBackendStore {
                        $obj->set_etag( md5_file( $params['src'] ) );
                        // Use the same content type as StreamFile for security
                        $obj->content_type = StreamFile::contentTypeFromPath( $params['dst'] );
+                       if ( !strlen( $obj->content_type ) ) { // special case
+                               $obj->content_type = 'unknown/unknown';
+                       }
                        if ( !empty( $params['async'] ) ) { // deferred
                                wfSuppressWarnings();
                                $fp = fopen( $params['src'], 'rb' );
@@ -1051,16 +1057,17 @@ class SwiftFileBackend extends FileBackendStore {
         * Set read/write permissions for a Swift container.
         *
         * $readGrps is a list of the possible criteria for a request to have
-        * access to write to a container. Each item is of the following format:
-        *   account:user       - Grants access if the request is by this user
+        * access to read a container. Each item is one of the following formats:
+        *   - account:user       : Grants access if the request is by the given user
+        *   - .r:<regex>         : Grants access if the request is from a referrer host that
+        *                          matches the expression and the request is not for a listing.
+        *                          Setting this to '*' effectively makes a container public.
+        *   - .rlistings:<regex> : Grants access if the request is from a referrer host that
+        *                          matches the expression and the request for a listing.
         *
         * $writeGrps is a list of the possible criteria for a request to have
-        * access to read a container. Each item is one of the following formats:
-        *   .r:<regex>         - Grants access if the request is from a referrer host that
-        *                        matches the expression and the request is not for a listing.
-        *                        Setting this to '*' effectively makes a container public.
-        *   .rlistings:<regex> - Grants access if the request is from a referrer host that
-        *                        matches the expression and the request for a listing.
+        * access to write to a container. Each item is of the following format:
+        *   - account:user       : Grants access if the request is by the given user
         *
         * @see http://swift.openstack.org/misc.html#acls
         *
@@ -1295,7 +1302,7 @@ abstract class SwiftFileBackendList implements Iterator {
        protected $dir; // string; storage directory
        protected $suffixStart; // integer
 
-       const PAGE_SIZE = 5000; // file listing buffer size
+       const PAGE_SIZE = 9000; // file listing buffer size
 
        /**
         * @param $backend SwiftFileBackend