Go back to Status objects after r71805. We return an Ok result if it can give a meani...
authorPlatonides <platonides@users.mediawiki.org>
Wed, 15 Sep 2010 21:03:07 +0000 (21:03 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 15 Sep 2010 21:03:07 +0000 (21:03 +0000)
Remove the now unused colonsToAssoc().
Better diffed without whitespaces.

includes/Article.php
includes/PoolCounter.php
languages/messages/MessagesEn.php

index 753e157..e02ca66 100644 (file)
@@ -4660,11 +4660,7 @@ class PoolWorkArticleView extends PoolCounterWork {
                $wgOut->enableClientCache( false );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                
-               if ( $status instanceof Status ) {
-                       $errortext = $status->getWikiText( false, 'view-pool-error' );
-               } else {
-                       $errortext = wfMsgNoTrans( 'view-pool-error', '' );
-               }
+               $errortext = $status->getWikiText( false, 'view-pool-error' );
                $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
                
                return false;
index 8b6e18a..caf7e12 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() {
@@ -146,35 +146,43 @@ abstract class PoolCounterWork {
                }
                
                $result = false;
-               switch ( is_int( $status ) ? $status : PoolCounter::ERROR ) {
-                       case PoolCounter::LOCKED:
-                               $result = $this->doWork();
-                               $this->poolCounter->release();
-                               return $result;
-                       
-                       case PoolCounter::DONE:
-                               $result = $this->getCachedWork();
-                               if ( $result === false ) {
-                                       /* That someone else work didn't serve us.
-                                        * Acquire the lock for me
-                                        */
-                                       return $this->execute( true );
-                               }
-                               return $result;
-                               
-                       case PoolCounter::QUEUE_FULL:
-                       case PoolCounter::TIMEOUT:
-                               $result = $this->fallback();
+               
+               if ( $status->isOK() ) {
+                       switch ( $status->value ) {
+                               case PoolCounter::LOCKED:
+                                       $result = $this->doWork();
+                                       $this->poolCounter->release();
+                                       return $result;
                                
-                               if ( $result !== false ) {
+                               case PoolCounter::DONE:
+                                       $result = $this->getCachedWork();
+                                       if ( $result === false ) {
+                                               /* That someone else work didn't serve us.
+                                                * Acquire the lock for me
+                                                */
+                                               return $this->execute( true );
+                                       }
                                        return $result;
-                               }
-                               /* no break */
-                       
-                       case PoolCounter::ERROR:
-                       default:
-                               return $this->error( $status );
+                                       
+                               case PoolCounter::QUEUE_FULL:
+                               case PoolCounter::TIMEOUT:
+                                       $result = $this->fallback();
+                                       
+                                       if ( $result !== false ) {
+                                               return $result;
+                                       }
+                                       /* 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' );
+                                       /* continue to the error */
+                       }
                }
+               return $this->error( $status );
        }
        
        function __construct( $type, $key ) {
index b718449..5fa8933 100644 (file)
@@ -858,6 +858,9 @@ Too many users are trying to view this page.
 Please wait a while before you try to access this page again.
 
 $1',
+'pool-timeout'       => 'Timeout waiting for the lock',
+'pool-queuefull'     => 'Pool queue is full',
+'pool-errorunknown'  => 'Unknown error',
 
 # All link text and link target definitions of links into project namespace that get used by other message strings, with the exception of user group pages (see grouppage) and the disambiguation template definition (see disambiguations).
 'aboutsite'            => 'About {{SITENAME}}',