r106596 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106595‎ | r106596 | r106597 >
Date:20:19, 18 December 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Removed canMove() from FSFileBackend, left from r106585.
* Made multiwrite doOperations() respect 'nonLocking'.
* Added/fixed more doc comments.
* Moved FileBackend::move() down a bit.
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/FileOp.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/DBLockManager.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/FSLockManager.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LSLockManager.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LockManager.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LockManagerGroup.php (modified) (history)
  • /branches/FileBackend/phase3/includes/filerepo/file/File.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/includes/filerepo/file/File.php
@@ -1150,7 +1150,7 @@
11511151 */
11521152 function getThumbUrl( $suffix = false ) {
11531153 $this->assertRepoDefined();
1154 - $path = $this->repo->getZoneUrl('thumb') . '/' . $this->getUrlRel();
 1154+ $path = $this->repo->getZoneUrl( 'thumb' ) . '/' . $this->getUrlRel();
11551155 if ( $suffix !== false ) {
11561156 $path .= '/' . rawurlencode( $suffix );
11571157 }
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
@@ -2,6 +2,7 @@
33 /**
44 * @file
55 * @ingroup FileBackend
 6+ * @author Aaron Schulz
67 */
78
89 /**
@@ -71,7 +72,7 @@
7273 foreach ( $this->fileBackends as $index => $backend ) {
7374 $backendOps = $this->substOpPaths( $ops, $backend );
7475 $performOps = array_merge( $performOps, $backend->getOperations( $backendOps ) );
75 - if ( $index == 0 ) {
 76+ if ( $index == 0 && empty( $opts['nonLocking'] ) ) {
7677 // Set "files to lock" from the first batch so we don't try to set all
7778 // locks two or three times over (depending on the number of backends).
7879 // A lock on one storage path is a lock on all the backends.
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/DBLockManager.php
@@ -12,6 +12,8 @@
1313 * A majority of peer DBs must agree for a lock to be acquired.
1414 *
1515 * Caching is used to avoid hitting servers that are down.
 16+ *
 17+ * @ingroup LockManager
1618 */
1719 class DBLockManager extends LockManager {
1820 /** @var Array Map of DB names to server config */
@@ -374,6 +376,8 @@
375377 /**
376378 * MySQL version of DBLockManager that supports shared locks.
377379 * All locks are non-blocking, which avoids deadlocks.
 380+ *
 381+ * @ingroup LockManager
378382 */
379383 class MySqlLockManager extends DBLockManager {
380384 /** @var Array Mapping of lock types to the type actually used */
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/FSLockManager.php
@@ -8,6 +8,8 @@
99 * Do not use this with 'lockDir' set to an NFS mount unless the
1010 * NFS client is at least version 2.6.12. Otherwise, the BSD flock()
1111 * locks will be ignored; see http://nfs.sourceforge.net/#section_d.
 12+ *
 13+ * @ingroup LockManager
1214 */
1315 class FSLockManager extends LockManager {
1416 /** @var Array Mapping of lock types to the type actually used */
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LockManagerGroup.php
@@ -2,7 +2,7 @@
33 /**
44 * Class to handle file lock manager registration
55 *
6 - * @ingroup FileBackend
 6+ * @ingroup LockManager
77 */
88 class LockManagerGroup {
99 protected static $instance = null;
@@ -57,7 +57,7 @@
5858 if ( !isset( $this->managers[$name] ) ) {
5959 throw new MWException( "No lock manager defined with the name `$name`." );
6060 }
61 - // Lazy-load the actual backend instance
 61+ // Lazy-load the actual lock manager instance
6262 if ( !isset( $this->managers[$name]['instance'] ) ) {
6363 $class = $this->managers[$name]['class'];
6464 $config = $this->managers[$name]['config'];
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LSLockManager.php
@@ -9,6 +9,8 @@
1010 * to one bucket. Each bucket maps to one or several peer servers, each
1111 * running LockServerDaemon.php, listening on a designated TCP port.
1212 * A majority of peers must agree for a lock to be acquired.
 13+ *
 14+ * @ingroup LockManager
1315 */
1416 class LSLockManager extends LockManager {
1517 /** @var Array Mapping of lock types to the type actually used */
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LockManager.php
@@ -1,5 +1,11 @@
22 <?php
33 /**
 4+ * @file
 5+ * @ingroup LockManager
 6+ * @author Aaron Schulz
 7+ */
 8+
 9+/**
410 * Class for handling resource locking.
511 * Locks on resource keys can either be shared or exclusive.
612 *
@@ -9,8 +15,9 @@
1016 * Locks should either be non-blocking or have low wait timeouts.
1117 *
1218 * Subclasses should avoid throwing exceptions at all costs.
13 - *
14 - * @ingroup FileBackend
 19+ *
 20+ * @ingroup LockManager
 21+ * @since 1.19
1522 */
1623 abstract class LockManager {
1724 /* Lock types; stronger locks have higher values */
@@ -78,6 +85,9 @@
7986 /**
8087 * LockManager helper class to handle scoped locks, which
8188 * release when an object is destroyed or goes out of scope.
 89+ *
 90+ * @ingroup LockManager
 91+ * @since 1.19
8292 */
8393 class ScopedLock {
8494 /** @var LockManager */
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
@@ -2,6 +2,7 @@
33 /**
44 * @file
55 * @ingroup FileBackend
 6+ * @author Aaron Schulz
67 */
78
89 /**
@@ -12,6 +13,7 @@
1314 * potentially many FileOp classes in large arrays in memory.
1415 *
1516 * @ingroup FileBackend
 17+ * @since 1.19
1618 */
1719 abstract class FileOp {
1820 /** $var Array */
Index: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php
@@ -2,6 +2,7 @@
33 /**
44 * @file
55 * @ingroup FileBackend
 6+ * @author Aaron Schulz
67 */
78
89 /**
@@ -126,10 +127,6 @@
127128 return $status;
128129 }
129130
130 - function canMove( array $params ) {
131 - return true;
132 - }
133 -
134131 function move( array $params ) {
135132 $status = Status::newGood();
136133
Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php
@@ -2,6 +2,7 @@
33 /**
44 * @file
55 * @ingroup FileBackend
 6+ * @author Aaron Schulz
67 */
78
89 /**
@@ -21,6 +22,7 @@
2223 * As a corollary, external dependencies should be kept to a minimum.
2324 *
2425 * @ingroup FileBackend
 26+ * @since 1.19
2527 */
2628 abstract class FileBackendBase {
2729 protected $name; // unique backend name
@@ -111,8 +113,7 @@
112114 * 'op' => 'concatenate',
113115 * 'srcs' => <ordered array of storage paths>,
114116 * 'dst' => <storage path>,
115 - * 'overwriteDest' => <boolean>,
116 - * 'overwriteSame' => <boolean>
 117+ * 'overwriteDest' => <boolean>
117118 * )
118119 * g) Do nothing (no-op)
119120 * array(
@@ -352,6 +353,7 @@
353354 * This class defines the methods as abstract that subclasses must implement.
354355 *
355356 * @ingroup FileBackend
 357+ * @since 1.19
356358 */
357359 abstract class FileBackend extends FileBackendBase {
358360 /**
@@ -381,6 +383,17 @@
382384 abstract public function copy( array $params );
383385
384386 /**
 387+ * Delete a file at the storage path.
 388+ * Do not call this function from places outside FileBackend and FileOp.
 389+ * $params include:
 390+ * src : source storage path
 391+ *
 392+ * @param $params Array
 393+ * @return Status
 394+ */
 395+ abstract public function delete( array $params );
 396+
 397+ /**
385398 * Move a file from one storage path to another in the backend.
386399 * Do not call this function from places outside FileBackend and FileOp.
387400 * $params include:
@@ -403,17 +416,6 @@
404417 }
405418
406419 /**
407 - * Delete a file at the storage path.
408 - * Do not call this function from places outside FileBackend and FileOp.
409 - * $params include:
410 - * src : source storage path
411 - *
412 - * @param $params Array
413 - * @return Status
414 - */
415 - abstract public function delete( array $params );
416 -
417 - /**
418420 * Combines files from several storage paths into a new file in the backend.
419421 * Do not call this function from places outside FileBackend and FileOp.
420422 * $params include:
@@ -548,7 +550,7 @@
549551 // Build up a list of FileOps...
550552 $performOps = $this->getOperations( $ops );
551553
552 - if ( !isset( $opts['nonLocking'] ) || !$opts['nonLocking'] ) {
 554+ if ( empty( $opts['nonLocking'] ) ) {
553555 // Build up a list of files to lock...
554556 $filesLockEx = $filesLockSh = array();
555557 foreach ( $performOps as $index => $fileOp ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106585* Added default copy+delete implementation for move() and removed canMove()...aaron19:23, 18 December 2011

Status & tagging log