r93446 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93445‎ | r93446 | r93447 >
Date:05:51, 29 July 2011
Author:aaron
Status:ok
Tags:
Comment:
More error handling and validation cleanups for getActiveWikiVersions()
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/activeMWVersions (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions
@@ -1,5 +1,6 @@
22 #!/usr/bin/env php
33 <?php
 4+error_reporting( 0 );
45 /*
56 * Returns a space separated list of all active MW versions (e.g. "x.xx").
67 * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
@@ -7,6 +8,7 @@
89 * Given --home, versions are instead read from /home/wikipedia/common/wikiversions.cdb.
910 * Given --withdb, each item in the list will be appended with '=' followed by
1011 * the DB name of *some* wiki that uses that version. Used to run maintenance scripts.
 12+ * Given --report, error messages would be displayed if this dies.
1113 *
1214 * @return string
1315 */
@@ -23,13 +25,22 @@
2426
2527 $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
2628 if ( !count( $verList ) ) {
27 - die( "Unable to read wikiversions.dat.\n" );
 29+ if ( in_array( '--report', $options ) ) {
 30+ echo( "Unable to read wikiversions.dat.\n" );
 31+ }
 32+ die( 1 );
2833 }
2934
3035 $result = $activeVersions = array();
3136 foreach ( $verList as $item ) {
3237 list( $dbname, $version ) = explode( ' ', $item );
33 - $version = str_replace( 'php-', '', $version ); // remove 'php-'
 38+ if ( substr( $version, 0, 4 ) !== 'php-' ) {
 39+ if ( in_array( '--report', $options ) ) {
 40+ echo( "Unable to read wikiversions.dat entry: $version.\n" );
 41+ }
 42+ die( 1 );
 43+ }
 44+ $version = substr( $version, 4 ); // remove 'php-'
3445 if ( !isset( $activeVersions[$version] ) ) {
3546 $activeVersions[$version] = 1;
3647 if ( in_array( '--withdb', $options ) ) {

Status & tagging log