https://www.mediawiki.org/wiki/Special:Code/MediaWiki/108303
Revision: 108303
Author: aaron
Date: 2012-01-07 03:17:17 +0000 (Sat, 07 Jan 2012)
Log Message:
-----------
Partially reverted bits from r108300. Not allowing underscores is too
restrictive and breaks on default DB name value suggested by installer. Azure
can use resolveContainerName() to enforce its extra restrictions. A new
resolveWikiId() function was added to allow for it to mangle the wiki ID by
translating underscores. Also restored previous size limit in
isValidContainerName() since it makes sense to either go all the way
lowest-common-denominator or not here (in this case not). Preserved "first char
is a alphanumeric" check since it's pretty weird to have anything else.
Modified Paths:
--------------
trunk/phase3/includes/filerepo/backend/FileBackend.php
Modified: trunk/phase3/includes/filerepo/backend/FileBackend.php
===================================================================
--- trunk/phase3/includes/filerepo/backend/FileBackend.php 2012-01-07
01:53:27 UTC (rev 108302)
+++ trunk/phase3/includes/filerepo/backend/FileBackend.php 2012-01-07
03:17:17 UTC (rev 108303)
@@ -43,6 +43,7 @@
* $config includes:
* 'name' : The unique name of this backend.
* 'wikiId' : Prefix to container names that is unique to this
wiki.
+ * This should consist of alphanumberic, '-', and
'_' chars.
* 'lockManager' : Registered name of a file lock manager to use.
* 'readOnly' : Write operations are disallowed if this is a
non-empty string.
* It should be an explanation for the backend
being read-only.
@@ -53,7 +54,8 @@
$this->name = $config['name'];
$this->wikiId = isset( $config['wikiId'] )
? $config['wikiId']
- : rtrim( wfWikiID(), '_' ); // "mywiki-en_" =>
"mywiki-en"
+ : wfWikiID(); // e.g. "my_wiki-en_"
+ $this->wikiId = $this->resolveWikiId( $this->wikiId );
$this->lockManager = LockManagerGroup::singleton()->get(
$config['lockManager'] );
$this->readOnly = isset( $config['readOnly'] )
? (string)$config['readOnly']
@@ -61,6 +63,17 @@
}
/**
+ * Normalize a wiki ID by replacing characters that are
+ * not supported by the backend as part of container names.
+ *
+ * @param $wikiId string
+ * @return string
+ */
+ protected function resolveWikiId( $wikiId ) {
+ return $wikiId;
+ }
+
+ /**
* Get the unique backend name.
*
* We may have multiple different backends of the same type.
@@ -1104,10 +1117,11 @@
* @return bool
*/
final protected static function isValidContainerName( $container ) {
- // This accounts for Swift, S3, and Azure restrictions while
- // leaving room for '.xxx' (hex shard chars) or '.seg'
(segments).
- // Note that matching strings URL encode to the same string.
- return preg_match( '/^[a-z0-9][a-z0-9-]{2,55}$/i', $container );
+ // This accounts for Swift and S3 restrictions while leaving
room
+ // for things like '.xxx' (hex shard chars) or '.seg'
(segments).
+ // Note that matching strings URL encode to the same string;
+ // in Swift, the length resriction is *after* URL encoding.
+ return preg_match( '/^[a-z0-9][a-z0-9-_]{0,199}$/i', $container
);
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs