Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
— | — | @@ -232,14 +232,16 @@ |
233 | 233 | if ( $db ) { |
234 | 234 | $version = dba_fetch( "ver:{$this->db}", $db ); |
235 | 235 | if ( $version === false ) { |
236 | | - die( "wikiversions.cdb has no version entry for `$db`.\n" ); |
237 | | - } elseif ( strpos( $version, 'php-' ) !== 0 ) { |
238 | | - die( "wikiversions.cdb version entry does not start with `php-` (got `$version`).\n" ); |
| 236 | + $extraVersion = false; |
| 237 | + } else { |
| 238 | + if ( strpos( $version, 'php-' ) !== 0 ) { |
| 239 | + die( "wikiversions.cdb version entry does not start with `php-` (got `$version`).\n" ); |
| 240 | + } |
| 241 | + $extraVersion = dba_fetch( "ext:{$this->db}", $db ); |
| 242 | + if ( $extraVersion === false ) { |
| 243 | + die( "wikiversions.cdb has no extra version entry for `$db`.\n" ); |
| 244 | + } |
239 | 245 | } |
240 | | - $extraVersion = dba_fetch( "ext:{$this->db}", $db ); |
241 | | - if ( $extraVersion === false ) { |
242 | | - die( "wikiversions.cdb has no extra version entry for `$db`.\n" ); |
243 | | - } |
244 | 246 | } else { |
245 | 247 | //trigger_error( "Unable to open wikiversions.cdb. Assuming php-1.17", E_USER_ERROR ); |
246 | 248 | $version = 'php-1.17'; |
— | — | @@ -252,6 +254,26 @@ |
253 | 255 | } |
254 | 256 | |
255 | 257 | /** |
| 258 | + * Sanity check that this wiki actually exists. |
| 259 | + * @return bool |
| 260 | + */ |
| 261 | + private function assertNotMissing() { |
| 262 | + if ( $this->isMissing() ) { |
| 263 | + die( "wikiversions.cdb has no version entry for `{$this->db}`.\n" ); |
| 264 | + } |
| 265 | + } |
| 266 | + |
| 267 | + /** |
| 268 | + * Check if this wiki is *not* specified in a cdb file |
| 269 | + * located at /usr/local/apache/common/wikiversions.cdb. |
| 270 | + * @return bool |
| 271 | + */ |
| 272 | + public function isMissing() { |
| 273 | + $this->loadVersionInfo(); |
| 274 | + return ( $this->version === false ); |
| 275 | + } |
| 276 | + |
| 277 | + /** |
256 | 278 | * Get the version as specified in a cdb file located |
257 | 279 | * at /usr/local/apache/common/wikiversions.cdb. |
258 | 280 | * Result is of the form "php-X.XX" or "php-trunk". |
— | — | @@ -259,6 +281,7 @@ |
260 | 282 | */ |
261 | 283 | public function getVersion() { |
262 | 284 | $this->loadVersionInfo(); |
| 285 | + $this->assertNotMissing(); // caller should have checked isMissing() |
263 | 286 | return $this->version; |
264 | 287 | } |
265 | 288 | |
— | — | @@ -270,6 +293,7 @@ |
271 | 294 | */ |
272 | 295 | public function getVersionNumber() { |
273 | 296 | $this->loadVersionInfo(); |
| 297 | + $this->assertNotMissing(); // caller should have checked isMissing() |
274 | 298 | return substr( $this->version, 4 ); // remove "php-" |
275 | 299 | } |
276 | 300 | |
— | — | @@ -282,6 +306,7 @@ |
283 | 307 | */ |
284 | 308 | public function getExtendedVersionNumber() { |
285 | 309 | $this->loadVersionInfo(); |
| 310 | + $this->assertNotMissing(); // caller should have checked isMissing() |
286 | 311 | $ver = $this->getVersionNumber(); |
287 | 312 | if ( $this->extVersion !== '' ) { |
288 | 313 | $ver .= "-{$this->extVersion}"; |