r98342 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98341‎ | r98342 | r98343 >
Date:18:19, 28 September 2011
Author:aaron
Status:ok
Tags:
Comment:
* Added defines.php class to hold some directory constants
* A few style cleanups
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/MWVersion.php (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/activeMWVersions (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/defines.php (added) (history)
  • /trunk/tools/mwmultiversion/multiversion/getMWVersion (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/refreshWikiversionsCDB (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/MWVersion.php
@@ -17,12 +17,12 @@
1818 */
1919 function getMediaWiki( $file ) {
2020 global $IP;
 21+ require( dirname( __FILE__ ) . '/MWMultiVersion.php' );
2122
2223 $scriptName = @$_SERVER['SCRIPT_NAME'];
2324 $serverName = @$_SERVER['SERVER_NAME'];
2425 $documentRoot = @$_SERVER['DOCUMENT_ROOT'];
2526
26 - require( dirname( __FILE__ ) . '/MWMultiVersion.php' );
2727 # Upload URL hit (to upload.wikimedia.org rather than wiki of origin)...
2828 if ( $scriptName === '/w/thumb.php' && $serverName === 'upload.wikimedia.org' ) {
2929 $multiVersion = MWMultiVersion::initializeForUploadWiki( $_SERVER['PATH_INFO'] );
Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis
@@ -1,6 +1,7 @@
22 #!/usr/bin/env php
33 <?php
44 error_reporting( E_ALL );
 5+requre_once( dirname( __FILE__ ) . '/defines.php' );
56 /*
67 * This script switches all wikis running one version to another version.
78 * It merely changes the wikiversions.dat and wikiversions.cdb files on /home,
@@ -33,8 +34,8 @@
3435 die( "The directory `$common/$newVersion` does not exist.\n" );
3536 }
3637
37 - $path = "$common/wikiversions.dat";
38 - $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
 38+ $datPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat';
 39+ $verList = array_filter( explode( "\n", file_get_contents( $datPath ) ) );
3940 if ( !count( $verList ) ) {
4041 die( "Unable to read wikiversions.dat.\n" );
4142 }
@@ -61,13 +62,13 @@
6263
6364 # Backup old wikiversions.dat...
6465 $backupPath = "$common/multiversion/backup/wikiversions-" . time() . ".dat";
65 - if ( !copy( "$common/wikiversions.dat", $backupPath ) ) {
 66+ if ( !copy( $datPath, $backupPath ) ) {
6667 die( "Unable to write backup file `$backupPath`.\n" );
6768 }
6869 echo "Wrote backup file `$backupPath`.\n";
6970
7071 # Update wikiversions.dat...
71 - if ( !file_put_contents( $path, $datList ) ) {
 72+ if ( !file_put_contents( $datPath, $datList ) ) {
7273 die( "Unable to write to wikiversions.dat.\n" );
7374 }
7475 # Rebuild wikiversions.cdb...
Index: trunk/tools/mwmultiversion/multiversion/defines.php
@@ -0,0 +1,6 @@
 2+<?php
 3+/**
 4+ * Define installation specific MWMultiVersion values like paths
 5+ */
 6+define( 'MULTIVER_CDB_DIR_HOME', '/home/wikipedia/common' );
 7+define( 'MULTIVER_CDB_DIR_APACHE', '/usr/local/apache/common-local' );
Property changes on: trunk/tools/mwmultiversion/multiversion/defines.php
___________________________________________________________________
Added: svn:eol-style
18 + native
Index: trunk/tools/mwmultiversion/multiversion/refreshWikiversionsCDB
@@ -1,22 +1,21 @@
22 #!/usr/bin/env php
33 <?php
44 error_reporting( E_ALL );
 5+requre_once( dirname( __FILE__ ) . '/defines.php' );
56 /*
67 * Populate wikiversions.cdb file using all the items in wikiversions.dat
78 *
89 * @return void
910 */
1011 function refreshWikiversionsCDB() {
11 - $common = '/home/wikipedia/common';
12 -
13 - $path = "$common/wikiversions.dat";
 12+ $path = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat';
1413 $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
1514 if ( !count( $verList ) ) {
1615 die( "Unable to read wikiversions.dat.\n" );
1716 }
1817
19 - $tmpDBPath = "$common/wikiversions.cdb.tmp";
20 - $finalDBPath = "$common/wikiversions.cdb";
 18+ $tmpDBPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.cdb.tmp';
 19+ $finalDBPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.cdb';
2120
2221 # Build new database at temp location...
2322 $db = dba_open( $tmpDBPath, "n", "cdb_make" );
Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions
@@ -1,6 +1,7 @@
22 #!/usr/bin/env php
33 <?php
44 error_reporting( 0 );
 5+requre_once( dirname( __FILE__ ) . '/defines.php' );
56 /*
67 * Returns a space separated list of all active MW versions (e.g. "x.xx").
78 * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
@@ -20,9 +21,9 @@
2122 array_shift( $options ); // first item is this file
2223
2324 if ( in_array( '--home', $options ) ) {
24 - $path = '/home/wikipedia/common/wikiversions.dat';
 25+ $path = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat';
2526 } else {
26 - $path = '/usr/local/apache/common-local/wikiversions.dat';
 27+ $path = MULTIVER_CDB_DIR_APACHE . '/wikiversions.dat';
2728 }
2829
2930 $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
Index: trunk/tools/mwmultiversion/multiversion/getMWVersion
@@ -1,7 +1,10 @@
22 #!/usr/bin/env php
33 <?php
44 error_reporting( 0 );
5 -// This script prints the MW version associated with a specified wikidb.
 5+requre_once( dirname( __FILE__ ) . '/defines.php' );
 6+/**
 7+ * This script prints the MW version associated with a specified wikidb.
 8+ */
69 if ( count( $argv ) < 2 ) {
710 print "Usage: getMWVersion <dbname> \n";
811 exit( 1 );
@@ -12,7 +15,7 @@
1316 * @return string MW code version (e.g. "php-x.xx" or "php-trunk")
1417 */
1518 function getWikiVersion( $dbName ) {
16 - $db = dba_open( '/usr/local/apache/common-local/wikiversions.cdb', 'r', 'cdb' );
 19+ $db = dba_open( MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb', 'r', 'cdb' );
1720 if ( $db ) {
1821 $version = dba_fetch( "ver:$dbName", $db );
1922 dba_close( $db );
Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php
@@ -1,4 +1,5 @@
22 <?php
 3+requre_once( dirname( __FILE__ ) . '/defines.php' );
34 /**
45 * Class to handle basic information related to what
56 * version of MediaWiki is running on a wiki installation.
@@ -6,7 +7,6 @@
78 * Avoid setting environmental or globals variables here for OOP.
89 */
910 class MWMultiVersion {
10 -
1111 /**
1212 * @var MWMultiVersion
1313 */
@@ -223,7 +223,7 @@
224224 }
225225 $this->versionLoaded = true;
226226
227 - $db = dba_open( '/usr/local/apache/common-local/wikiversions.cdb', 'r', 'cdb' );
 227+ $db = dba_open( MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb', 'r', 'cdb' );
228228 if ( $db ) {
229229 $version = dba_fetch( "ver:{$this->db}", $db );
230230 if ( $version === false ) {

Status & tagging log