r73089 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73088‎ | r73089 | r73090 >
Date:21:03, 15 September 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/extensions/PoolCounter/PoolCounterClient_body.php (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/PoolCounter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -4660,11 +4660,7 @@
46614661 $wgOut->enableClientCache( false );
46624662 $wgOut->setRobotPolicy( 'noindex,nofollow' );
46634663
4664 - if ( $status instanceof Status ) {
4665 - $errortext = $status->getWikiText( false, 'view-pool-error' );
4666 - } else {
4667 - $errortext = wfMsgNoTrans( 'view-pool-error', '' );
4668 - }
 4664+ $errortext = $status->getWikiText( false, 'view-pool-error' );
46694665 $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
46704666
46714667 return false;
Index: trunk/phase3/includes/PoolCounter.php
@@ -84,15 +84,15 @@
8585
8686 class PoolCounter_Stub extends PoolCounter {
8787 function acquireForMe() {
88 - return PoolCounter::LOCKED;
 88+ return Status::newGood( PoolCounter::LOCKED );
8989 }
9090
9191 function acquireForAnyone() {
92 - return PoolCounter::LOCKED;
 92+ return Status::newGood( PoolCounter::LOCKED );
9393 }
9494
9595 function release() {
96 - return PoolCounter::RELEASED;
 96+ return Status::newGood( PoolCounter::RELEASED );
9797 }
9898
9999 public function __construct() {
@@ -146,35 +146,43 @@
147147 }
148148
149149 $result = false;
150 - switch ( is_int( $status ) ? $status : PoolCounter::ERROR ) {
151 - case PoolCounter::LOCKED:
152 - $result = $this->doWork();
153 - $this->poolCounter->release();
154 - return $result;
155 -
156 - case PoolCounter::DONE:
157 - $result = $this->getCachedWork();
158 - if ( $result === false ) {
159 - /* That someone else work didn't serve us.
160 - * Acquire the lock for me
161 - */
162 - return $this->execute( true );
163 - }
164 - return $result;
 150+
 151+ if ( $status->isOK() ) {
 152+ switch ( $status->value ) {
 153+ case PoolCounter::LOCKED:
 154+ $result = $this->doWork();
 155+ $this->poolCounter->release();
 156+ return $result;
165157
166 - case PoolCounter::QUEUE_FULL:
167 - case PoolCounter::TIMEOUT:
168 - $result = $this->fallback();
 158+ case PoolCounter::DONE:
 159+ $result = $this->getCachedWork();
 160+ if ( $result === false ) {
 161+ /* That someone else work didn't serve us.
 162+ * Acquire the lock for me
 163+ */
 164+ return $this->execute( true );
 165+ }
 166+ return $result;
 167+
 168+ case PoolCounter::QUEUE_FULL:
 169+ case PoolCounter::TIMEOUT:
 170+ $result = $this->fallback();
 171+
 172+ if ( $result !== false ) {
 173+ return $result;
 174+ }
 175+ /* no break */
169176
170 - if ( $result !== false ) {
171 - return $result;
172 - }
173 - /* no break */
174 -
175 - case PoolCounter::ERROR:
176 - default:
177 - return $this->error( $status );
 177+ /* These two cases should never be hit... */
 178+ case PoolCounter::ERROR:
 179+ default:
 180+ $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' );
 181+
 182+ $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' );
 183+ /* continue to the error */
 184+ }
178185 }
 186+ return $this->error( $status );
179187 }
180188
181189 function __construct( $type, $key ) {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -858,6 +858,9 @@
859859 Please wait a while before you try to access this page again.
860860
861861 $1',
 862+'pool-timeout' => 'Timeout waiting for the lock',
 863+'pool-queuefull' => 'Pool queue is full',
 864+'pool-errorunknown' => 'Unknown error',
862865
863866 # 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).
864867 'aboutsite' => 'About {{SITENAME}}',
Index: trunk/extensions/PoolCounter/PoolCounterClient_body.php
@@ -29,7 +29,9 @@
3030 if ( count( $parts ) < 2 ) {
3131 $parts[] = 7531;
3232 }
 33+ wfSuppressWarnings();
3334 $conn = fsockopen( $parts[0], $parts[1], $errno, $errstr, $this->timeout );
 35+ wfRestoreWarnings();
3436 if ( $conn ) {
3537 break;
3638 }
@@ -115,22 +117,10 @@
116118 case 'QUEUE_FULL':
117119 case 'TIMEOUT':
118120 case 'LOCK_HELD':
119 - return constant( "PoolCounter::$responseType" );
 121+ return Status::newGood( constant( "PoolCounter::$responseType" ) );
120122 }
121123 }
122124
123 - function colonsToAssoc( $items ) {
124 - $assoc = array();
125 - foreach ( $items as $item ) {
126 - $parts = explode( ':', $item, 2 );
127 - if ( count( $parts ) !== 2 ) {
128 - continue;
129 - }
130 - $assoc[$parts[0]] = $parts[1];
131 - }
132 - return $assoc;
133 - }
134 -
135125 function acquireForMe() {
136126 return $this->sendCommand( 'ACQ4ME', $this->key, $this->workers, $this->maxqueue, $this->timeout );
137127 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r73094List r73089 message aditions.platonides22:35, 15 September 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71805Make a bunch of incompatible changes to the PoolCounter....platonides20:57, 27 August 2010

Comments

#Comment by Siebrand (talk | contribs)   22:11, 15 September 2010

Please update messages.inc when adding core messages.

#Comment by Platonides (talk | contribs)   22:35, 15 September 2010

Argh. Fixed in r73094.

Status & tagging log