r103950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103949‎ | r103950 | r103951 >
Date:20:02, 22 November 2011
Author:aaron
Status:deferred
Tags:
Comment:
* 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 (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php
@@ -36,7 +36,7 @@
3737 * Cleans up after the temporary file.
3838 * Currently this means removing it from the local disk.
3939 */
40 - protected function __destruct() {
 40+ function __destruct() {
4141 if ( $this->canDelete ) {
4242 wfSuppressWarnings();
4343 unlink( $this->path );
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
@@ -30,7 +30,7 @@
3131 * $config contains:
3232 * 'name' : The name of the proxy backend
3333 * 'lockManger' : FileLockManager instance
34 - * 'backends' : Array of ( backend object, settings ) pairs.
 34+ * 'backends' : Array of (backend object, settings) pairs.
3535 * The settings per backend include:
3636 * 'isCache': The backend is non-persistent
3737 * @param $config Array
Index: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php
@@ -344,7 +344,7 @@
345345 }
346346
347347 /**
348 - * Simple DFS based file browsing iterator. The highest number of file handles
 348+ * Semi-DFS based file browsing iterator. The highest number of file handles
349349 * open at any given time is proportional to the height of the directory tree.
350350 */
351351 class FileIterator implements Iterator {
@@ -413,13 +413,13 @@
414414 }
415415 list( $dir, $handle ) = $set;
416416 while ( false !== ( $file = readdir( $handle ) ) ) {
417 - // Exclude '.' and '..' as well .svn or .lock type files.
418 - // Also excludes symlinks and the like so as to avoid cycles.
419 - if ( $file[0] !== '.' && !is_link( $file ) ) {
 417+ // Exclude '.' and '..' as well .svn or .lock type files
 418+ if ( $file[0] !== '.' ) {
420419 // If the first thing we find is a file, then return it.
421420 // If the first thing we find is a directory, then return
422421 // the first file that it contains (via recursion).
423 - if ( is_dir( "$dir/$file" ) ) {
 422+ // We exclude symlink dirs in order to avoid cycles.
 423+ if ( is_dir( "$dir/$file" ) && !is_link( "$dir/$file" ) ) {
424424 $subHandle = opendir( "$dir/$file" );
425425 if ( $subHandle ) {
426426 $this->pushDirectory( "{$dir}/{$file}", $subHandle );
@@ -465,7 +465,7 @@
466466 $this->dirStack = array();
467467 }
468468
469 - private function __destruct() {
 469+ function __destruct() {
470470 $this->closeDirectories();
471471 }
472472 }
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php
@@ -46,7 +46,7 @@
4747 /**
4848 * Lock a resource with the given key
4949 *
50 - * @param $key Array List of keys to lock
 50+ * @param $key Array List of keys to lock (40 char hex hashes)
5151 * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH
5252 * @return string
5353 */
@@ -56,7 +56,7 @@
5757 * Unlock a resource with the given key.
5858 * If $type is given, then only locks of that type should be cleared.
5959 *
60 - * @param $key Array List of keys to unlock
 60+ * @param $key Array List of keys to unlock (40 char hex hashes)
6161 * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH, or 0
6262 * @return string
6363 */
@@ -188,7 +188,7 @@
189189 return $status;
190190 }
191191
192 - protected function __destruct() {
 192+ function __destruct() {
193193 // Make sure remaining files get cleared for sanity
194194 foreach ( $this->handles as $key => $locks ) {
195195 foreach ( $locks as $type => $handle ) {
@@ -404,12 +404,11 @@
405405 * Get the bucket for lock key.
406406 * This should avoid throwing any exceptions.
407407 *
408 - * @param $key string
 408+ * @param $key string (40 char hex key)
409409 * @return integer
410410 */
411411 protected function getBucketFromKey( $key ) {
412 - $hash = str_pad( md5( $key ), 32, '0', STR_PAD_LEFT ); // 32 char hash
413 - $prefix = substr( $hash, 0, 2 ); // first 2 hex chars (8 bits)
 412+ $prefix = substr( $key, 0, 2 ); // first 2 hex chars (8 bits)
414413 $bucket = intval( base_convert( $prefix, 16, 10 ) ) % count( $this->serverMap );
415414 // Sanity check that at least one server is handling this bucket
416415 if ( !isset( $this->serverMap[$bucket] ) ) {
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php
@@ -139,7 +139,8 @@
140140 abstract public function concatenate( array $params );
141141
142142 /**
143 - * Whether this backend implements move() and can handle a potential move.
 143+ * Whether this backend implements move() and is applies to a potential
 144+ * move from one storage path to another. No backends hits are required.
144145 * For example, moving objects accross containers may not be supported.
145146 * Do not call this function from places outside FileBackend and FileOp.
146147 * $params include:

Status & tagging log