Index: branches/FileBackend/phase3/includes/filerepo/file/TempLocalFile.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | * Cleans up after the temporary file. |
38 | 38 | * Currently this means removing it from the local disk. |
39 | 39 | */ |
40 | | - protected function __destruct() { |
| 40 | + function __destruct() { |
41 | 41 | if ( $this->canDelete ) { |
42 | 42 | wfSuppressWarnings(); |
43 | 43 | unlink( $this->path ); |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | * $config contains: |
32 | 32 | * 'name' : The name of the proxy backend |
33 | 33 | * 'lockManger' : FileLockManager instance |
34 | | - * 'backends' : Array of ( backend object, settings ) pairs. |
| 34 | + * 'backends' : Array of (backend object, settings) pairs. |
35 | 35 | * The settings per backend include: |
36 | 36 | * 'isCache': The backend is non-persistent |
37 | 37 | * @param $config Array |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php |
— | — | @@ -344,7 +344,7 @@ |
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
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 |
349 | 349 | * open at any given time is proportional to the height of the directory tree. |
350 | 350 | */ |
351 | 351 | class FileIterator implements Iterator { |
— | — | @@ -413,13 +413,13 @@ |
414 | 414 | } |
415 | 415 | list( $dir, $handle ) = $set; |
416 | 416 | 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] !== '.' ) { |
420 | 419 | // If the first thing we find is a file, then return it. |
421 | 420 | // If the first thing we find is a directory, then return |
422 | 421 | // 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" ) ) { |
424 | 424 | $subHandle = opendir( "$dir/$file" ); |
425 | 425 | if ( $subHandle ) { |
426 | 426 | $this->pushDirectory( "{$dir}/{$file}", $subHandle ); |
— | — | @@ -465,7 +465,7 @@ |
466 | 466 | $this->dirStack = array(); |
467 | 467 | } |
468 | 468 | |
469 | | - private function __destruct() { |
| 469 | + function __destruct() { |
470 | 470 | $this->closeDirectories(); |
471 | 471 | } |
472 | 472 | } |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileLockManager.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | /** |
48 | 48 | * Lock a resource with the given key |
49 | 49 | * |
50 | | - * @param $key Array List of keys to lock |
| 50 | + * @param $key Array List of keys to lock (40 char hex hashes) |
51 | 51 | * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH |
52 | 52 | * @return string |
53 | 53 | */ |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | * Unlock a resource with the given key. |
58 | 58 | * If $type is given, then only locks of that type should be cleared. |
59 | 59 | * |
60 | | - * @param $key Array List of keys to unlock |
| 60 | + * @param $key Array List of keys to unlock (40 char hex hashes) |
61 | 61 | * @param $type integer FileLockManager::LOCK_EX, FileLockManager::LOCK_SH, or 0 |
62 | 62 | * @return string |
63 | 63 | */ |
— | — | @@ -188,7 +188,7 @@ |
189 | 189 | return $status; |
190 | 190 | } |
191 | 191 | |
192 | | - protected function __destruct() { |
| 192 | + function __destruct() { |
193 | 193 | // Make sure remaining files get cleared for sanity |
194 | 194 | foreach ( $this->handles as $key => $locks ) { |
195 | 195 | foreach ( $locks as $type => $handle ) { |
— | — | @@ -404,12 +404,11 @@ |
405 | 405 | * Get the bucket for lock key. |
406 | 406 | * This should avoid throwing any exceptions. |
407 | 407 | * |
408 | | - * @param $key string |
| 408 | + * @param $key string (40 char hex key) |
409 | 409 | * @return integer |
410 | 410 | */ |
411 | 411 | 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) |
414 | 413 | $bucket = intval( base_convert( $prefix, 16, 10 ) ) % count( $this->serverMap ); |
415 | 414 | // Sanity check that at least one server is handling this bucket |
416 | 415 | if ( !isset( $this->serverMap[$bucket] ) ) { |
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -139,7 +139,8 @@ |
140 | 140 | abstract public function concatenate( array $params ); |
141 | 141 | |
142 | 142 | /** |
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. |
144 | 145 | * For example, moving objects accross containers may not be supported. |
145 | 146 | * Do not call this function from places outside FileBackend and FileOp. |
146 | 147 | * $params include: |