r106346 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106345‎ | r106346 | r106347 >
Date:18:12, 15 December 2011
Author:aaron
Status:ok
Tags:
Comment:
* Fixed order of isValidContainerName() check in resolveStoragePath()
* Added ScopedLock to autoloader
* Added base class remarks about directories
* Fixed some function comments
Modified paths:
  • /branches/FileBackend/phase3/includes/AutoLoader.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php
@@ -7,16 +7,19 @@
88 /**
99 * Base class for all file backend classes (including multi-write backends).
1010 * This class defines the methods as abstract that subclasses must implement.
11 - *
1211 * Outside callers can assume that all backends will have these functions.
1312 *
1413 * All "storage paths" are of the format "mwstore://backend/container/path".
1514 * The paths use typical file system (FS) notation, though any particular backend may
1615 * not actually be using a local filesystem. Therefore, the paths are only virtual.
17 - *
 16+ *
 17+ * FS-based backends are somewhat more restrictive due to the existence of real
 18+ * directory files; a regular file cannot have the same name as a directory. Other
 19+ * backends with virtual directories may not have this limitation.
 20+ *
1821 * Methods should avoid throwing exceptions at all costs.
1922 * As a corollary, external dependencies should be kept to a minimum.
20 - *
 23+ *
2124 * @ingroup FileBackend
2225 */
2326 abstract class FileBackendBase {
@@ -258,7 +261,7 @@
259262 * Results should be storage paths relative to the given directory.
260263 *
261264 * $params include:
262 - * dir : storage path directory.
 265+ * dir : storage path directory
263266 *
264267 * @return Iterator|Array
265268 */
@@ -301,7 +304,7 @@
302305 * Lock the files at the given storage paths in the backend.
303306 * This will either lock all the files or none (on failure).
304307 *
305 - * Avoid using this function outside of FileBackendScopedLock.
 308+ * Callers should consider using getScopedFileLocks() instead.
306309 *
307310 * @param $paths Array Storage paths
308311 * @param $type integer LockManager::LOCK_EX, LockManager::LOCK_SH
@@ -314,8 +317,6 @@
315318 /**
316319 * Unlock the files at the given storage paths in the backend.
317320 *
318 - * Avoid using this function outside of FileBackendScopedLock.
319 - *
320321 * @param $paths Array Storage paths
321322 * @param $type integer LockManager::LOCK_EX, LockManager::LOCK_SH
322323 * @return Status
@@ -335,7 +336,7 @@
336337 * @param $paths Array Storage paths
337338 * @param $type integer LockManager::LOCK_EX, LockManager::LOCK_SH
338339 * @param $status Status Status to update on lock/unlock
339 - * @return FileBackendScopedLock|null Returns null on failure
 340+ * @return ScopedLock|null Returns null on failure
340341 */
341342 final public function getScopedFileLocks( array $paths, $type, Status $status ) {
342343 return ScopedLock::factory( $this->lockManager, $paths, $type, $status );
@@ -658,13 +659,15 @@
659660 list( $backend, $container, $relPath ) = self::splitStoragePath( $storagePath );
660661 if ( $backend === $this->name ) { // must be for this backend
661662 $relPath = self::normalizeStoragePath( $relPath );
662 - if ( $relPath !== null && self::isValidContainerName( $container ) ) {
 663+ if ( $relPath !== null ) {
663664 $relPath = $this->resolveContainerPath( $container, $relPath );
664665 if ( $relPath !== null ) {
665666 $container = $this->fullContainerName( $container );
666 - $container = $this->resolveContainerName( $container );
667 - if ( $container !== null ) {
668 - return array( $container, $relPath ); // (container, path)
 667+ if ( self::isValidContainerName( $container ) ) {
 668+ $container = $this->resolveContainerName( $container );
 669+ if ( $container !== null ) {
 670+ return array( $container, $relPath );
 671+ }
669672 }
670673 }
671674 }
Index: branches/FileBackend/phase3/includes/AutoLoader.php
@@ -497,6 +497,7 @@
498498 'FSFileIterator' => 'includes/filerepo/backend/FSFileBackend.php',
499499 'LockManagerGroup' => 'includes/filerepo/backend/LockManagerGroup.php',
500500 'LockManager' => 'includes/filerepo/backend/LockManager.php',
 501+ 'ScopedLock' => 'includes/filerepo/backend/LockManager.php',
501502 'FSLockManager' => 'includes/filerepo/backend/LockManager.php',
502503 'DBLockManager' => 'includes/filerepo/backend/LockManager.php',
503504 'MySqlLockManager'=> 'includes/filerepo/backend/LockManager.php',

Status & tagging log