r93037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93036‎ | r93037 | r93038 >
Date:03:32, 25 July 2011
Author:aaron
Status:ok
Tags:
Comment:
w/s fixes
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/activeMWVersions (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions
@@ -1,47 +1,47 @@
2 -#!/usr/bin/env php
3 -<?php
4 -error_reporting( E_ALL );
5 -/*
6 - * Returns a space separated list of all active MW versions (e.g. "x.xx").
7 - * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
8 - *
9 - * Given --home, versions are instead read from /home/wikipedia/common/wikiversions.cdb.
10 - * Given --withdb, each item in the list will be appended with '=' followed by
11 - * the DB name of *some* wiki that uses that version. Used to run maintenance scripts.
12 - *
13 - * @return string
14 - */
15 -function getActiveWikiVersions() {
16 - global $argv;
17 - $options = $argv; // copy
18 - array_shift( $options ); // first item is this file
19 -
20 - if ( in_array( '--home', $options ) ) {
21 - $path = '/home/wikipedia/common/wikiversions.dat';
22 - } else {
23 - $path = '/usr/local/apache/common-local/wikiversions.dat';
24 - }
25 -
26 - $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
27 - if ( !count( $verList ) ) {
28 - die( "Unable to read wikiversions.dat.\n" );
29 - }
30 -
31 - $result = $activeVersions = array();
32 - foreach ( $verList as $item ) {
33 - list( $dbname, $version ) = explode( ' ', $item );
34 - $version = str_replace( 'php-', '', $version ); // remove 'php-'
35 - if ( !isset( $activeVersions[$version] ) ) {
36 - $activeVersions[$version] = 1;
37 - if ( in_array( '--withdb', $options ) ) {
38 - $result[] = "{$version}={$dbname}";
39 - } else {
40 - $result[] = "{$version}";
41 - }
42 - }
43 - }
44 -
45 - return implode( ' ', $result );
46 -}
47 -
48 -echo getActiveWikiVersions() . "\n";
 2+#!/usr/bin/env php
 3+<?php
 4+error_reporting( E_ALL );
 5+/*
 6+ * Returns a space separated list of all active MW versions (e.g. "x.xx").
 7+ * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
 8+ *
 9+ * Given --home, versions are instead read from /home/wikipedia/common/wikiversions.cdb.
 10+ * Given --withdb, each item in the list will be appended with '=' followed by
 11+ * the DB name of *some* wiki that uses that version. Used to run maintenance scripts.
 12+ *
 13+ * @return string
 14+ */
 15+function getActiveWikiVersions() {
 16+ global $argv;
 17+ $options = $argv; // copy
 18+ array_shift( $options ); // first item is this file
 19+
 20+ if ( in_array( '--home', $options ) ) {
 21+ $path = '/home/wikipedia/common/wikiversions.dat';
 22+ } else {
 23+ $path = '/usr/local/apache/common-local/wikiversions.dat';
 24+ }
 25+
 26+ $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
 27+ if ( !count( $verList ) ) {
 28+ die( "Unable to read wikiversions.dat.\n" );
 29+ }
 30+
 31+ $result = $activeVersions = array();
 32+ foreach ( $verList as $item ) {
 33+ list( $dbname, $version ) = explode( ' ', $item );
 34+ $version = str_replace( 'php-', '', $version ); // remove 'php-'
 35+ if ( !isset( $activeVersions[$version] ) ) {
 36+ $activeVersions[$version] = 1;
 37+ if ( in_array( '--withdb', $options ) ) {
 38+ $result[] = "{$version}={$dbname}";
 39+ } else {
 40+ $result[] = "{$version}";
 41+ }
 42+ }
 43+ }
 44+
 45+ return implode( ' ', $result );
 46+}
 47+
 48+echo getActiveWikiVersions() . "\n";

Status & tagging log