From df8cb36d403f9e7ac02ca267ad8df2ec92a6b207 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 15 Sep 2010 21:03:07 +0000 Subject: [PATCH] Go back to Status objects after r71805. We return an Ok result if it can give a meaningful result (eg. in fallback). Remove the now unused colonsToAssoc(). Better diffed without whitespaces. --- includes/Article.php | 6 +-- includes/PoolCounter.php | 66 +++++++++++++++++-------------- languages/messages/MessagesEn.php | 3 ++ 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 753e157beb..e02ca66a42 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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( '
' . $errortext . '
' ); return false; diff --git a/includes/PoolCounter.php b/includes/PoolCounter.php index 8b6e18aea6..caf7e124a0 100644 --- a/includes/PoolCounter.php +++ b/includes/PoolCounter.php @@ -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 ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b718449d70..5fa893370e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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}}', -- 2.20.1