r93634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93633‎ | r93634 | r93635 >
Date:17:46, 1 August 2011
Author:aaron
Status:ok
Tags:
Comment:
Changes for bug 30156: defer some die() msgs and added isMissing() function for use in CommonSettings
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php
@@ -232,14 +232,16 @@
233233 if ( $db ) {
234234 $version = dba_fetch( "ver:{$this->db}", $db );
235235 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+ }
239245 }
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 - }
244246 } else {
245247 //trigger_error( "Unable to open wikiversions.cdb. Assuming php-1.17", E_USER_ERROR );
246248 $version = 'php-1.17';
@@ -252,6 +254,26 @@
253255 }
254256
255257 /**
 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+ /**
256278 * Get the version as specified in a cdb file located
257279 * at /usr/local/apache/common/wikiversions.cdb.
258280 * Result is of the form "php-X.XX" or "php-trunk".
@@ -259,6 +281,7 @@
260282 */
261283 public function getVersion() {
262284 $this->loadVersionInfo();
 285+ $this->assertNotMissing(); // caller should have checked isMissing()
263286 return $this->version;
264287 }
265288
@@ -270,6 +293,7 @@
271294 */
272295 public function getVersionNumber() {
273296 $this->loadVersionInfo();
 297+ $this->assertNotMissing(); // caller should have checked isMissing()
274298 return substr( $this->version, 4 ); // remove "php-"
275299 }
276300
@@ -282,6 +306,7 @@
283307 */
284308 public function getExtendedVersionNumber() {
285309 $this->loadVersionInfo();
 310+ $this->assertNotMissing(); // caller should have checked isMissing()
286311 $ver = $this->getVersionNumber();
287312 if ( $this->extVersion !== '' ) {
288313 $ver .= "-{$this->extVersion}";

Follow-up revisions

RevisionCommit summaryAuthorDate
r93658Made MWVersion.php return missing.php for non-wikis for web-entry function. R...aaron21:19, 1 August 2011

Status & tagging log