Index: trunk/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | * $config includes: |
45 | 45 | * 'name' : The unique name of this backend. |
46 | 46 | * 'wikiId' : Prefix to container names that is unique to this wiki. |
| 47 | + * This should consist of alphanumberic, '-', and '_' chars. |
47 | 48 | * 'lockManager' : Registered name of a file lock manager to use. |
48 | 49 | * 'readOnly' : Write operations are disallowed if this is a non-empty string. |
49 | 50 | * It should be an explanation for the backend being read-only. |
— | — | @@ -53,7 +54,8 @@ |
54 | 55 | $this->name = $config['name']; |
55 | 56 | $this->wikiId = isset( $config['wikiId'] ) |
56 | 57 | ? $config['wikiId'] |
57 | | - : rtrim( wfWikiID(), '_' ); // "mywiki-en_" => "mywiki-en" |
| 58 | + : wfWikiID(); // e.g. "my_wiki-en_" |
| 59 | + $this->wikiId = $this->resolveWikiId( $this->wikiId ); |
58 | 60 | $this->lockManager = LockManagerGroup::singleton()->get( $config['lockManager'] ); |
59 | 61 | $this->readOnly = isset( $config['readOnly'] ) |
60 | 62 | ? (string)$config['readOnly'] |
— | — | @@ -61,6 +63,17 @@ |
62 | 64 | } |
63 | 65 | |
64 | 66 | /** |
| 67 | + * Normalize a wiki ID by replacing characters that are |
| 68 | + * not supported by the backend as part of container names. |
| 69 | + * |
| 70 | + * @param $wikiId string |
| 71 | + * @return string |
| 72 | + */ |
| 73 | + protected function resolveWikiId( $wikiId ) { |
| 74 | + return $wikiId; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
65 | 78 | * Get the unique backend name. |
66 | 79 | * |
67 | 80 | * We may have multiple different backends of the same type. |
— | — | @@ -1104,10 +1117,11 @@ |
1105 | 1118 | * @return bool |
1106 | 1119 | */ |
1107 | 1120 | final protected static function isValidContainerName( $container ) { |
1108 | | - // This accounts for Swift, S3, and Azure restrictions while |
1109 | | - // leaving room for '.xxx' (hex shard chars) or '.seg' (segments). |
1110 | | - // Note that matching strings URL encode to the same string. |
1111 | | - return preg_match( '/^[a-z0-9][a-z0-9-]{2,55}$/i', $container ); |
| 1121 | + // This accounts for Swift and S3 restrictions while leaving room |
| 1122 | + // for things like '.xxx' (hex shard chars) or '.seg' (segments). |
| 1123 | + // Note that matching strings URL encode to the same string; |
| 1124 | + // in Swift, the length resriction is *after* URL encoding. |
| 1125 | + return preg_match( '/^[a-z0-9][a-z0-9-_]{0,199}$/i', $container ); |
1112 | 1126 | } |
1113 | 1127 | |
1114 | 1128 | /** |