Tweaked some of the default LockManager ttls
[lhc/web/wiklou.git] / includes / filebackend / lockmanager / LockManager.php
index eca153b..762bc66 100644 (file)
  * @since 1.19
  */
 abstract class LockManager {
-       /** @var Array Mapping of lock types to the type actually used */
+       /** @var array Mapping of lock types to the type actually used */
        protected $lockTypeMap = array(
                self::LOCK_SH => self::LOCK_SH,
                self::LOCK_UW => self::LOCK_EX, // subclasses may use self::LOCK_SH
                self::LOCK_EX => self::LOCK_EX
        );
 
-       /** @var Array Map of (resource path => lock type => count) */
+       /** @var array Map of (resource path => lock type => count) */
        protected $locksHeld = array();
 
        protected $domain; // string; domain (usually wiki ID)
@@ -64,19 +64,17 @@ abstract class LockManager {
        /**
         * Construct a new instance from configuration
         *
-        * $config paramaters include:
+        * @param array $config Paramaters include:
         *   - domain  : Domain (usually wiki ID) that all resources are relative to [optional]
         *   - lockTTL : Age (in seconds) at which resource locks should expire.
         *               This only applies if locks are not tied to a connection/process.
-        *
-        * @param $config Array
         */
        public function __construct( array $config ) {
                $this->domain = isset( $config['domain'] ) ? $config['domain'] : wfWikiID();
                if ( isset( $config['lockTTL'] ) ) {
-                       $this->lockTTL = max( 1, $config['lockTTL'] );
+                       $this->lockTTL = max( 5, $config['lockTTL'] );
                } elseif ( PHP_SAPI === 'cli' ) {
-                       $this->lockTTL = 2 * 3600;
+                       $this->lockTTL = 3600;
                } else {
                        $met = ini_get( 'max_execution_time' ); // this is 0 in CLI mode
                        $this->lockTTL = max( 5 * 60, 2 * (int)$met );
@@ -87,8 +85,8 @@ abstract class LockManager {
         * Lock the resources at the given abstract paths
         *
         * @param array $paths List of resource names
-        * @param $type integer LockManager::LOCK_* constant
-        * @param integer $timeout Timeout in seconds (0 means non-blocking) (since 1.21)
+        * @param int $type LockManager::LOCK_* constant
+        * @param int $timeout Timeout in seconds (0 means non-blocking) (since 1.21)
         * @return Status
         */
        final public function lock( array $paths, $type = self::LOCK_EX, $timeout = 0 ) {
@@ -99,7 +97,7 @@ abstract class LockManager {
         * Lock the resources at the given abstract paths
         *
         * @param array $pathsByType Map of LockManager::LOCK_* constants to lists of paths
-        * @param integer $timeout Timeout in seconds (0 means non-blocking) (since 1.21)
+        * @param int $timeout Timeout in seconds (0 means non-blocking) (since 1.21)
         * @return Status
         * @since 1.22
         */
@@ -127,7 +125,7 @@ abstract class LockManager {
         * Unlock the resources at the given abstract paths
         *
         * @param array $paths List of paths
-        * @param $type integer LockManager::LOCK_* constant
+        * @param int $type LockManager::LOCK_* constant
         * @return Status
         */
        final public function unlock( array $paths, $type = self::LOCK_EX ) {
@@ -155,7 +153,7 @@ abstract class LockManager {
         * Before hashing, the path will be prefixed with the domain ID.
         * This should be used interally for lock key or file names.
         *
-        * @param $path string
+        * @param string $path
         * @return string
         */
        final protected function sha1Base36Absolute( $path ) {
@@ -167,7 +165,7 @@ abstract class LockManager {
         * Before hashing, the path will be prefixed with the domain ID.
         * This should be used interally for lock key or file names.
         *
-        * @param $path string
+        * @param string $path
         * @return string
         */
        final protected function sha1Base16Absolute( $path ) {
@@ -178,8 +176,8 @@ abstract class LockManager {
         * Normalize the $paths array by converting LOCK_UW locks into the
         * appropriate type and removing any duplicated paths for each lock type.
         *
-        * @param array $paths Map of LockManager::LOCK_* constants to lists of paths
-        * @return Array
+        * @param array $pathsByType Map of LockManager::LOCK_* constants to lists of paths
+        * @return array
         * @since 1.22
         */
        final protected function normalizePathsByType( array $pathsByType ) {
@@ -193,7 +191,7 @@ abstract class LockManager {
 
        /**
         * @see LockManager::lockByType()
-        * @param array $paths Map of LockManager::LOCK_* constants to lists of paths
+        * @param array $pathsByType Map of LockManager::LOCK_* constants to lists of paths
         * @return Status
         * @since 1.22
         */
@@ -206,8 +204,8 @@ abstract class LockManager {
                                $lockedByType[$type] = $paths;
                        } else {
                                // Release the subset of locks that were acquired
-                               foreach ( $lockedByType as $type => $paths ) {
-                                       $status->merge( $this->doUnlock( $paths, $type ) );
+                               foreach ( $lockedByType as $lType => $lPaths ) {
+                                       $status->merge( $this->doUnlock( $lPaths, $lType ) );
                                }
                                break;
                        }
@@ -220,14 +218,14 @@ abstract class LockManager {
         * Lock resources with the given keys and lock type
         *
         * @param array $paths List of paths
-        * @param $type integer LockManager::LOCK_* constant
+        * @param int $type LockManager::LOCK_* constant
         * @return Status
         */
        abstract protected function doLock( array $paths, $type );
 
        /**
         * @see LockManager::unlockByType()
-        * @param array $paths Map of LockManager::LOCK_* constants to lists of paths
+        * @param array $pathsByType Map of LockManager::LOCK_* constants to lists of paths
         * @return Status
         * @since 1.22
         */
@@ -244,7 +242,7 @@ abstract class LockManager {
         * Unlock resources with the given keys and lock type
         *
         * @param array $paths List of paths
-        * @param $type integer LockManager::LOCK_* constant
+        * @param int $type LockManager::LOCK_* constant
         * @return Status
         */
        abstract protected function doUnlock( array $paths, $type );