Index: trunk/phase3/includes/Article.php |
— | — | @@ -4660,11 +4660,7 @@ |
4661 | 4661 | $wgOut->enableClientCache( false ); |
4662 | 4662 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
4663 | 4663 | |
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' ); |
4669 | 4665 | $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' ); |
4670 | 4666 | |
4671 | 4667 | return false; |
Index: trunk/phase3/includes/PoolCounter.php |
— | — | @@ -84,15 +84,15 @@ |
85 | 85 | |
86 | 86 | class PoolCounter_Stub extends PoolCounter { |
87 | 87 | function acquireForMe() { |
88 | | - return PoolCounter::LOCKED; |
| 88 | + return Status::newGood( PoolCounter::LOCKED ); |
89 | 89 | } |
90 | 90 | |
91 | 91 | function acquireForAnyone() { |
92 | | - return PoolCounter::LOCKED; |
| 92 | + return Status::newGood( PoolCounter::LOCKED ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | function release() { |
96 | | - return PoolCounter::RELEASED; |
| 96 | + return Status::newGood( PoolCounter::RELEASED ); |
97 | 97 | } |
98 | 98 | |
99 | 99 | public function __construct() { |
— | — | @@ -146,35 +146,43 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | $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; |
165 | 157 | |
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 */ |
169 | 176 | |
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 | + } |
178 | 185 | } |
| 186 | + return $this->error( $status ); |
179 | 187 | } |
180 | 188 | |
181 | 189 | function __construct( $type, $key ) { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -858,6 +858,9 @@ |
859 | 859 | Please wait a while before you try to access this page again. |
860 | 860 | |
861 | 861 | $1', |
| 862 | +'pool-timeout' => 'Timeout waiting for the lock', |
| 863 | +'pool-queuefull' => 'Pool queue is full', |
| 864 | +'pool-errorunknown' => 'Unknown error', |
862 | 865 | |
863 | 866 | # 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). |
864 | 867 | 'aboutsite' => 'About {{SITENAME}}', |
Index: trunk/extensions/PoolCounter/PoolCounterClient_body.php |
— | — | @@ -29,7 +29,9 @@ |
30 | 30 | if ( count( $parts ) < 2 ) { |
31 | 31 | $parts[] = 7531; |
32 | 32 | } |
| 33 | + wfSuppressWarnings(); |
33 | 34 | $conn = fsockopen( $parts[0], $parts[1], $errno, $errstr, $this->timeout ); |
| 35 | + wfRestoreWarnings(); |
34 | 36 | if ( $conn ) { |
35 | 37 | break; |
36 | 38 | } |
— | — | @@ -115,22 +117,10 @@ |
116 | 118 | case 'QUEUE_FULL': |
117 | 119 | case 'TIMEOUT': |
118 | 120 | case 'LOCK_HELD': |
119 | | - return constant( "PoolCounter::$responseType" ); |
| 121 | + return Status::newGood( constant( "PoolCounter::$responseType" ) ); |
120 | 122 | } |
121 | 123 | } |
122 | 124 | |
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 | | - |
135 | 125 | function acquireForMe() { |
136 | 126 | return $this->sendCommand( 'ACQ4ME', $this->key, $this->workers, $this->maxqueue, $this->timeout ); |
137 | 127 | } |