https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103950
Revision: 103950 Author: aaron Date: 2011-11-22 20:02:12 +0000 (Tue, 22 Nov 2011) Log Message: ----------- * Simplified DBFileLockManager::getBucketFromKey() since we know the input is already a hash * Loosed symlink restricitons in FileIterator class * __destruct() has to be public Modified Paths: -------------- branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php Modified: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php 2011-11-22 19:59:18 UTC (rev 103949) +++ branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php 2011-11-22 20:02:12 UTC (rev 103950) @@ -344,7 +344,7 @@ } /** - * Simple DFS based file browsing iterator. The highest number of file handles + * Semi-DFS based file browsing iterator. The highest number of file handles * open at any given time is proportional to the height of the directory tree. */ class FileIterator implements Iterator { @@ -413,13 +413,13 @@ } list( $dir, $handle ) = $set; while ( false !== ( $file = readdir( $handle ) ) ) { - // Exclude '.' and '..' as well .svn or .lock type files. - // Also excludes symlinks and the like so as to avoid cycles. - if ( $file[0] !== '.' && !is_link( $file ) ) { + // Exclude '.' and '..' as well .svn or .lock type files + if ( $file[0] !== '.' ) { // If the first thing we find is a file, then return it. // If the first thing we find is a directory, then return // the first file that it contains (via recursion). - if ( is_dir( "$dir/$file" ) ) { + // We exclude symlink dirs in order to avoid cycles. + if ( is_dir( "$dir/$file" ) && !is_link( "$dir/$file" ) ) { $subHandle = opendir( "$dir/$file" ); if ( $subHandle ) { $this->pushDirectory( "{$dir}/{$file}", $subHandle ); @@ -465,7 +465,7 @@ $this->dirStack = array(); } - private function __destruct() { + function __destruct() { $this->closeDirectories(); } } Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php 2011-11-22 19:59:18 UTC (rev 103949) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php 2011-11-22 20:02:12 UTC (rev 103950) @@ -139,7 +139,8 @@ abstract public function concatenate( array $params ); /** - * Whether this backend implements move() and can handle a potential move. + * Whether this backend implements move() and is applies to a potential + * move from one storage path to another. No backends hits are required. * For example, moving objects accross containers may not be supported. * Do not call this function from places outside FileBackend and FileOp. * $params include: Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 2011-11-22 19:59:18 UTC (rev 103949) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 2011-11-22 20:02:12 UTC (rev 103950) @@ -30,7 +30,7 @@ * $config contains: * 'name' : The name of the proxy backend * 'lockManger' : FileLockManager instance - * 'backends' : Array of ( backend object, settings ) pairs. + * 'backends' : Array of (backend object, settings) pairs. * The settings per backend include: * 'isCache': The backend is non-persistent * @param $config Array Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php 2011-11-22 19:59:18 UTC (rev 103949) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php 2011-11-22 20:02:12 UTC (rev 103950) @@ -46,7 +46,7 @@ /** * Lock a resource with the given key * - * @param $key Array List of keys to lock + * @param $key Array List of keys to lock (40 char hex hashes) * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH * @return string */ @@ -56,7 +56,7 @@ * Unlock a resource with the given key. * If $type is given, then only locks of that type should be cleared. * - * @param $key Array List of keys to unlock + * @param $key Array List of keys to unlock (40 char hex hashes) * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH, or 0 * @return string */ @@ -188,7 +188,7 @@ return $status; } - protected function __destruct() { + function __destruct() { // Make sure remaining files get cleared for sanity foreach ( $this->handles as $key => $locks ) { foreach ( $locks as $type => $handle ) { @@ -404,12 +404,11 @@ * Get the bucket for lock key. * This should avoid throwing any exceptions. * - * @param $key string + * @param $key string (40 char hex key) * @return integer */ protected function getBucketFromKey( $key ) { - $hash = str_pad( md5( $key ), 32, '0', STR_PAD_LEFT ); // 32 char hash - $prefix = substr( $hash, 0, 2 ); // first 2 hex chars (8 bits) + $prefix = substr( $key, 0, 2 ); // first 2 hex chars (8 bits) $bucket = intval( base_convert( $prefix, 16, 10 ) ) % count( $this->serverMap ); // Sanity check that at least one server is handling this bucket if ( !isset( $this->serverMap[$bucket] ) ) { Modified: branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php 2011-11-22 19:59:18 UTC (rev 103949) +++ branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php 2011-11-22 20:02:12 UTC (rev 103950) @@ -36,7 +36,7 @@ * Cleans up after the temporary file. * Currently this means removing it from the local disk. */ - protected function __destruct() { + function __destruct() { if ( $this->canDelete ) { wfSuppressWarnings(); unlink( $this->path ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs