Bump RL filter version to 4 to keep it in sync with the cluster. WMF-centrism, I...
[lhc/web/wiklou.git] / includes / PoolCounter.php
index 8b6e18a..25bdd2d 100644 (file)
@@ -84,15 +84,15 @@ abstract class PoolCounter {
 
 class PoolCounter_Stub extends PoolCounter {
        function acquireForMe() {
-               return PoolCounter::LOCKED;
+               return Status::newGood( PoolCounter::LOCKED );
        }
 
        function acquireForAnyone() {
-               return PoolCounter::LOCKED;
+               return Status::newGood( PoolCounter::LOCKED );
        }
 
        function release() {
-               return PoolCounter::RELEASED;
+               return Status::newGood( PoolCounter::RELEASED );
        }
        
        public function __construct() {
@@ -134,6 +134,13 @@ abstract class PoolCounterWork {
        function error( $status ) {     
                return false;
        }
+
+       /**
+        * Log an error
+        */
+       function logError( $status ) {
+               wfDebugLog( 'poolcounter', $status->getWikiText() );
+       }
        
        /**
         * Get the result of the work (whatever it is), or false.
@@ -144,9 +151,14 @@ abstract class PoolCounterWork {
                } else {
                        $status = $this->poolCounter->acquireForMe();
                }
-               
-               $result = false;
-               switch ( is_int( $status ) ? $status : PoolCounter::ERROR ) {
+
+               if ( !$status->isOK() ) {
+                       // Respond gracefully to complete server breakage: just log it and do the work
+                       $this->logError( $status );
+                       return $this->doWork();
+               }
+
+               switch ( $status->value ) {
                        case PoolCounter::LOCKED:
                                $result = $this->doWork();
                                $this->poolCounter->release();
@@ -171,8 +183,13 @@ abstract class PoolCounterWork {
                                }
                                /* no break */
                        
+                       /* These two cases should never be hit... */
                        case PoolCounter::ERROR:
                        default:
+                               $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' );
+                               
+                               $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' );
+                               $this->logError( $status );
                                return $this->error( $status );
                }
        }