Index: trunk/tools/mwmultiversion/multiversion/MWVersion.php |
— | — | @@ -17,12 +17,12 @@ |
18 | 18 | */ |
19 | 19 | function getMediaWiki( $file ) { |
20 | 20 | global $IP; |
| 21 | + require( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
21 | 22 | |
22 | 23 | $scriptName = @$_SERVER['SCRIPT_NAME']; |
23 | 24 | $serverName = @$_SERVER['SERVER_NAME']; |
24 | 25 | $documentRoot = @$_SERVER['DOCUMENT_ROOT']; |
25 | 26 | |
26 | | - require( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
27 | 27 | # Upload URL hit (to upload.wikimedia.org rather than wiki of origin)... |
28 | 28 | if ( $scriptName === '/w/thumb.php' && $serverName === 'upload.wikimedia.org' ) { |
29 | 29 | $multiVersion = MWMultiVersion::initializeForUploadWiki( $_SERVER['PATH_INFO'] ); |
Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | #!/usr/bin/env php |
3 | 3 | <?php |
4 | 4 | error_reporting( E_ALL ); |
| 5 | +requre_once( dirname( __FILE__ ) . '/defines.php' ); |
5 | 6 | /* |
6 | 7 | * This script switches all wikis running one version to another version. |
7 | 8 | * It merely changes the wikiversions.dat and wikiversions.cdb files on /home, |
— | — | @@ -33,8 +34,8 @@ |
34 | 35 | die( "The directory `$common/$newVersion` does not exist.\n" ); |
35 | 36 | } |
36 | 37 | |
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 ) ) ); |
39 | 40 | if ( !count( $verList ) ) { |
40 | 41 | die( "Unable to read wikiversions.dat.\n" ); |
41 | 42 | } |
— | — | @@ -61,13 +62,13 @@ |
62 | 63 | |
63 | 64 | # Backup old wikiversions.dat... |
64 | 65 | $backupPath = "$common/multiversion/backup/wikiversions-" . time() . ".dat"; |
65 | | - if ( !copy( "$common/wikiversions.dat", $backupPath ) ) { |
| 66 | + if ( !copy( $datPath, $backupPath ) ) { |
66 | 67 | die( "Unable to write backup file `$backupPath`.\n" ); |
67 | 68 | } |
68 | 69 | echo "Wrote backup file `$backupPath`.\n"; |
69 | 70 | |
70 | 71 | # Update wikiversions.dat... |
71 | | - if ( !file_put_contents( $path, $datList ) ) { |
| 72 | + if ( !file_put_contents( $datPath, $datList ) ) { |
72 | 73 | die( "Unable to write to wikiversions.dat.\n" ); |
73 | 74 | } |
74 | 75 | # 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 |
1 | 8 | + native |
Index: trunk/tools/mwmultiversion/multiversion/refreshWikiversionsCDB |
— | — | @@ -1,22 +1,21 @@ |
2 | 2 | #!/usr/bin/env php |
3 | 3 | <?php |
4 | 4 | error_reporting( E_ALL ); |
| 5 | +requre_once( dirname( __FILE__ ) . '/defines.php' ); |
5 | 6 | /* |
6 | 7 | * Populate wikiversions.cdb file using all the items in wikiversions.dat |
7 | 8 | * |
8 | 9 | * @return void |
9 | 10 | */ |
10 | 11 | function refreshWikiversionsCDB() { |
11 | | - $common = '/home/wikipedia/common'; |
12 | | - |
13 | | - $path = "$common/wikiversions.dat"; |
| 12 | + $path = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat'; |
14 | 13 | $verList = array_filter( explode( "\n", file_get_contents( $path ) ) ); |
15 | 14 | if ( !count( $verList ) ) { |
16 | 15 | die( "Unable to read wikiversions.dat.\n" ); |
17 | 16 | } |
18 | 17 | |
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'; |
21 | 20 | |
22 | 21 | # Build new database at temp location... |
23 | 22 | $db = dba_open( $tmpDBPath, "n", "cdb_make" ); |
Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | #!/usr/bin/env php |
3 | 3 | <?php |
4 | 4 | error_reporting( 0 ); |
| 5 | +requre_once( dirname( __FILE__ ) . '/defines.php' ); |
5 | 6 | /* |
6 | 7 | * Returns a space separated list of all active MW versions (e.g. "x.xx"). |
7 | 8 | * Versions are read from /usr/local/apache/common-local/wikiversions.cdb. |
— | — | @@ -20,9 +21,9 @@ |
21 | 22 | array_shift( $options ); // first item is this file |
22 | 23 | |
23 | 24 | if ( in_array( '--home', $options ) ) { |
24 | | - $path = '/home/wikipedia/common/wikiversions.dat'; |
| 25 | + $path = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat'; |
25 | 26 | } else { |
26 | | - $path = '/usr/local/apache/common-local/wikiversions.dat'; |
| 27 | + $path = MULTIVER_CDB_DIR_APACHE . '/wikiversions.dat'; |
27 | 28 | } |
28 | 29 | |
29 | 30 | $verList = array_filter( explode( "\n", file_get_contents( $path ) ) ); |
Index: trunk/tools/mwmultiversion/multiversion/getMWVersion |
— | — | @@ -1,7 +1,10 @@ |
2 | 2 | #!/usr/bin/env php |
3 | 3 | <?php |
4 | 4 | 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 | + */ |
6 | 9 | if ( count( $argv ) < 2 ) { |
7 | 10 | print "Usage: getMWVersion <dbname> \n"; |
8 | 11 | exit( 1 ); |
— | — | @@ -12,7 +15,7 @@ |
13 | 16 | * @return string MW code version (e.g. "php-x.xx" or "php-trunk") |
14 | 17 | */ |
15 | 18 | 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' ); |
17 | 20 | if ( $db ) { |
18 | 21 | $version = dba_fetch( "ver:$dbName", $db ); |
19 | 22 | dba_close( $db ); |
Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | +requre_once( dirname( __FILE__ ) . '/defines.php' ); |
3 | 4 | /** |
4 | 5 | * Class to handle basic information related to what |
5 | 6 | * version of MediaWiki is running on a wiki installation. |
— | — | @@ -6,7 +7,6 @@ |
7 | 8 | * Avoid setting environmental or globals variables here for OOP. |
8 | 9 | */ |
9 | 10 | class MWMultiVersion { |
10 | | - |
11 | 11 | /** |
12 | 12 | * @var MWMultiVersion |
13 | 13 | */ |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | } |
225 | 225 | $this->versionLoaded = true; |
226 | 226 | |
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' ); |
228 | 228 | if ( $db ) { |
229 | 229 | $version = dba_fetch( "ver:{$this->db}", $db ); |
230 | 230 | if ( $version === false ) { |