Merge "Use quickUserCan instead of userCan for searches"
[lhc/web/wiklou.git] / includes / poolcounter / PoolCounterWork.php
index 50ddd90..1bc1a8b 100644 (file)
  * Class for dealing with PoolCounters using class members
  */
 abstract class PoolCounterWork {
-       protected $cacheable = false; //Does this override getCachedWork() ?
+       /** @var string */
+       protected $type = 'generic';
+       /** @var bool */
+       protected $cacheable = false; // does this override getCachedWork() ?
 
        /**
         * @param string $type The type of PoolCounter to use
         * @param string $key Key that identifies the queue this work is placed on
         */
        public function __construct( $type, $key ) {
+               $this->type = $type;
                $this->poolCounter = PoolCounter::factory( $type, $key );
        }
 
        /**
         * Actually perform the work, caching it if needed
-        * @return mixed work result or false
+        * @return mixed Work result or false
         */
        abstract public function doWork();
 
        /**
         * Retrieve the work from cache
-        * @return mixed work result or false
+        * @return mixed Work result or false
         */
        public function getCachedWork() {
                return false;
@@ -52,7 +56,7 @@ abstract class PoolCounterWork {
        /**
         * A work not so good (eg. expired one) but better than an error
         * message.
-        * @return mixed work result or false
+        * @return mixed Work result or false
         */
        public function fallback() {
                return false;
@@ -69,13 +73,13 @@ abstract class PoolCounterWork {
        /**
         * Log an error
         *
-        * @param $status Status
+        * @param Status $status
         * @return void
         */
        public function logError( $status ) {
                $key = $this->poolCounter->getKey();
 
-               wfDebugLog( 'poolcounter', "Pool key '$key': "
+               wfDebugLog( 'poolcounter', "Pool key '$key' ({$this->type}): "
                        . $status->getMessage()->inLanguage( 'en' )->useDatabase( false )->text() );
        }
 
@@ -91,7 +95,7 @@ abstract class PoolCounterWork {
         *   - c) fallback()     : Applies for all remaining cases.
         * If these all fall through (by returning false), then the result of error() is returned.
         *
-        * @param $skipcache bool
+        * @param bool $skipcache
         * @return mixed
         */
        public function execute( $skipcache = false ) {
@@ -108,6 +112,10 @@ abstract class PoolCounterWork {
                }
 
                switch ( $status->value ) {
+                       case PoolCounter::LOCK_HELD:
+                               // Better to ignore nesting pool counter limits than to fail.
+                               // Assume that the outer pool limiting is reasonable enough.
+                               /* no break */
                        case PoolCounter::LOCKED:
                                $result = $this->doWork();
                                $this->poolCounter->release();