Index: trunk/tools/mwmultiversion/checkoutMediaWiki.php |
— | — | @@ -1,125 +0,0 @@ |
2 | | -<?php |
3 | | -if ( php_sapi_name() !== 'cli' ) { |
4 | | - die( 'This script can only be run from the command line.' ); |
5 | | -} |
6 | | - |
7 | | -error_reporting( E_ALL ); |
8 | | - |
9 | | -/** |
10 | | - * Automatically SVN checkout a MediaWiki version and do some basic wmf setup. |
11 | | - * LocalSettings.php will be created (which loads CommonSettings.php) and verious |
12 | | - * symlinks will also be created. |
13 | | - * |
14 | | - * The first argument is the SVN directory (relative to mediawiki/branches/wmf). |
15 | | - * This is typically a version of the format "X.XXwmfX" ("e.g. 1.17wmf1"). |
16 | | - * The second argument is the target path (relative to /home/wikipedia/common/) |
17 | | - * to store local copy of the SVN checkout. This is typically of the format "php-X.XX". |
18 | | - * |
19 | | - * The script will not run if files already existing in the target directory. |
20 | | - * Also, assume the user running this script must have an SVN account |
21 | | - * with the SSH agent/key available. |
22 | | - * |
23 | | - * @return void |
24 | | - */ |
25 | | -function checkoutMediaWiki() { |
26 | | - global $argv; |
27 | | - $commonDir = '/home/wikipedia/common'; |
28 | | - |
29 | | - $argsValid = false; |
30 | | - if ( count( $argv ) >= 3 ) { |
31 | | - $svnVersion = $argv[1]; // e.g. "X.XXwmfX" |
32 | | - $dstVersion = $argv[2]; // e.g. "php-X.XX" |
33 | | - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $dstVersion, $m ) ) { |
34 | | - $dstVersionNum = $m[1]; |
35 | | - $argsValid = true; |
36 | | - } |
37 | | - } |
38 | | - |
39 | | - if ( !$argsValid ) { |
40 | | - die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX" ); |
41 | | - } |
42 | | - |
43 | | - # The url to SVN to checkout from |
44 | | - $source = "svn+ssh://svn.wikimedia.org/svnroot/mediawiki/branches/wmf/$svnVersion"; |
45 | | - |
46 | | - # Create the destination path to SVN checkout to... |
47 | | - $destIP = "$commonDir/$dstVersion"; |
48 | | - if ( file_exists( $destIP ) ) { |
49 | | - die( "Cannot checkout, the directory $destIP already exists.\n" ); |
50 | | - } |
51 | | - print "Creating checkout directory $destIP..."; |
52 | | - mkdir( $destIP, 0775 ); |
53 | | - print "done.\n"; |
54 | | - |
55 | | - print "Checking out $source to $destIP...\n"; |
56 | | - # Checkout the SVN directory... |
57 | | - $retval = 1; // error by default? |
58 | | - passthru( "svn checkout $source $destIP", $retval ); |
59 | | - if ( $retval !== 0 ) { |
60 | | - rmdir( $destIP ); // rollback |
61 | | - die( "\nUnable to checkout SVN path." ); |
62 | | - } |
63 | | - print "...SVN checkout done.\n"; |
64 | | - |
65 | | - $localSettingsCode = <<<EOT |
66 | | -<?php |
67 | | -# WARNING: This file is publically viewable on the web. Do not put private data here. |
68 | | -if ( defined('TESTWIKI') ) { |
69 | | - include_once( "/home/wikipedia/common/wmf-config/CommonSettings.php" ); |
70 | | -} else { |
71 | | - include_once( "/apache/common/wmf-config/CommonSettings.php" ); |
72 | | -} |
73 | | -EOT; |
74 | | - |
75 | | - # Create LocalSettings.php stub... |
76 | | - $path = "$destIP/LocalSettings.php"; |
77 | | - if ( !file_exists( $path ) ) { |
78 | | - if ( file_put_contents( $path, $localSettingsCode ) ) { |
79 | | - print "Created LocalSettings.php file.\n"; |
80 | | - } |
81 | | - } else { |
82 | | - print "File already exists: $path\n"; |
83 | | - } |
84 | | - |
85 | | - # Create symlink to wmf-config/AdminSettings.php... |
86 | | - $path = "$destIP/AdminSettings.php"; |
87 | | - if ( !file_exists( $path ) ) { |
88 | | - if ( symlink( "../wmf-config/AdminSettings.php", $path ) ) { |
89 | | - print "Created AdminSettings.php symlink.\n"; |
90 | | - } |
91 | | - } else { |
92 | | - print "File already exists: $path\n"; |
93 | | - } |
94 | | - |
95 | | - # Create symlink to wmf-config/StartProfiler.php... |
96 | | - $path = "$destIP/StartProfiler.php"; |
97 | | - if ( !file_exists( $path ) ) { |
98 | | - if ( symlink( "../wmf-config/StartProfiler.php", $path ) ) { |
99 | | - print "Created StartProfiler.php symlink.\n"; |
100 | | - } |
101 | | - } else { |
102 | | - print "File already exists: $path\n"; |
103 | | - } |
104 | | - |
105 | | - # Create bits.wikimedia.org symlinks... |
106 | | - $path = "$commonDir/docroot/bits/skins-$dstVersionNum"; |
107 | | - if ( !file_exists( $path ) ) { |
108 | | - if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/skins/", $path ) ) { |
109 | | - print "Created skins-$dstVersionNum symlink.\n"; |
110 | | - } |
111 | | - } else { |
112 | | - print "File already exists: $path\n"; |
113 | | - } |
114 | | - $path = "$commonDir/docroot/bits/w/extensions-$dstVersionNum"; |
115 | | - if ( !file_exists( $path ) ) { |
116 | | - if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/extensions", $path ) ) { |
117 | | - print "Created w/extensions-$dstVersionNum symlink.\n"; |
118 | | - } |
119 | | - } else { |
120 | | - print "File already exists: $path\n"; |
121 | | - } |
122 | | - |
123 | | - print "MediaWiki $dstVersionNum, from $svnVersion, successfully checked out.\n"; |
124 | | -} |
125 | | - |
126 | | -checkoutMediaWiki(); |
Index: trunk/tools/mwmultiversion/populateWikiversionCDB.php |
— | — | @@ -1,49 +0,0 @@ |
2 | | -<?php |
3 | | -if ( php_sapi_name() !== 'cli' ) { |
4 | | - die( 'This script can only be run from the command line.' ); |
5 | | -} |
6 | | - |
7 | | -error_reporting( E_ALL ); |
8 | | - |
9 | | -/* |
10 | | - * Populate wikiversions.cdb file using all the items in all.dblist |
11 | | - * as keys, each having a value of the specified MediaWiki version. |
12 | | - * This means that all will be configured to run that version. |
13 | | - * |
14 | | - * The first argument is the version, typically of the format "php-X.XX". |
15 | | - * |
16 | | - * @return void |
17 | | - */ |
18 | | -function populateWikiversionsCDB() { |
19 | | - global $argv; |
20 | | - |
21 | | - $argsValid = false; |
22 | | - if ( count( $argv ) >= 2 ) { |
23 | | - $version = $argv[1]; // e.g. "php-X.XX" |
24 | | - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $version ) ) { |
25 | | - $argsValid = true; |
26 | | - } |
27 | | - } |
28 | | - |
29 | | - if ( !$argsValid ) { |
30 | | - die( "Usage: populateWikiVersionsCDB.php php-X.XX" ); |
31 | | - } |
32 | | - |
33 | | - $path = '/home/wikipedia/common/all.dblist'; |
34 | | - $dbList = explode( "\n", file_get_contents( $path ) ); |
35 | | - if ( !count( $dbList ) ) { |
36 | | - die( "Unable to read all.dblist." ); |
37 | | - } |
38 | | - |
39 | | - $wikiVersionList = ''; |
40 | | - foreach ( $dbList as $dbName ) { |
41 | | - $wikiVersionList .= "$dbName $version\n"; |
42 | | - } |
43 | | - |
44 | | - $path = '/home/wikipedia/common/wikiversions.cdb'; |
45 | | - if ( !file_put_contents( $path, $wikiVersionList ) ) { |
46 | | - die( "Unable to write to wikiversions.cdb." ); |
47 | | - } |
48 | | -} |
49 | | - |
50 | | -populateWikiversionsCDB(); |
Index: trunk/tools/mwmultiversion/MWScript.php |
— | — | @@ -1,52 +0,0 @@ |
2 | | -<?php |
3 | | -if ( php_sapi_name() !== 'cli' ) { |
4 | | - exit; // sanity, script run via CLI |
5 | | -} |
6 | | - |
7 | | -error_reporting( E_ALL ); |
8 | | - |
9 | | -/** |
10 | | - * Run a MediaWiki script based on the parameters (like --wiki) given to CLI. |
11 | | - * |
12 | | - * The first argument must be the relative (to MediaWiki) script file path. |
13 | | - * If only a filename is given, it will be assumed to reside in /maintenance. |
14 | | - * The second argument must be the --wiki parameter. This is to avoid |
15 | | - * any "options with args" ambiguity (see Maintenance.php). |
16 | | - * |
17 | | - * When the actual script is run, $argv[0] (this file's name) will be not be kept. |
18 | | - * Also, $argv[1] (the script path) will be changed to the script file name. |
19 | | - * All other arguments will be preserved. |
20 | | - * |
21 | | - * @return void |
22 | | - */ |
23 | | -function runMWScript() { |
24 | | - global $argv; |
25 | | - if ( count( $argv ) < 2 ) { |
26 | | - die( "The MediaWiki script file path must be the first argument." ); |
27 | | - } |
28 | | - |
29 | | - $relFile = $argv[1]; // the script file to run |
30 | | - # If no MW directory is given then assume this is a /maintenance script |
31 | | - if ( strpos( $relFile, '/' ) === false ) { |
32 | | - $relFile = "maintenance/$relFile"; // convenience |
33 | | - } |
34 | | - |
35 | | - # Remove effects of this wrapper from $argv... |
36 | | - array_shift( $argv ); // remove this file's name from args |
37 | | - # Code stolen from wfBasename() in GlobalFunctions.php :) |
38 | | - if ( preg_match( "#([^/\\\\]*?)[/\\\\]*$#", $argv[0], $matches ) ) { |
39 | | - $argv[0] = $matches[1]; // make first arg the script file name |
40 | | - } |
41 | | - |
42 | | - # MWScript.php should be in common/ |
43 | | - require_once( dirname( __FILE__ ) . '/wmf-config/MWVersion.php' ); |
44 | | - $file = getMediaWikiCli( $relFile ); |
45 | | - if ( !file_exists( $file ) ) { |
46 | | - die( "The MediaWiki script file \"{$file}\" does not exist." ); |
47 | | - } |
48 | | - |
49 | | - # Run the script! (for HipHip, we will need to shell out here) |
50 | | - require_once( $file ); |
51 | | -} |
52 | | - |
53 | | -runMWScript(); |
Index: trunk/tools/mwmultiversion/multiversion/MWVersion.php |
— | — | @@ -0,0 +1,96 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Get the location of the correct version of a MediaWiki web |
| 5 | + * entry-point file given environmental variables such as the server name. |
| 6 | + * |
| 7 | + * This also has some other effects: |
| 8 | + * (a) Sets the $IP global variable (path to MediaWiki) |
| 9 | + * (b) Sets the MW_INSTALL_PATH environmental variable |
| 10 | + * (c) Changes PHP's current directory to the directory of this file. |
| 11 | + * |
| 12 | + * @param string File path (relative to MediaWiki dir) |
| 13 | + * @return string Absolute file path with proper MW location |
| 14 | + */ |
| 15 | +function getMediaWiki( $file ) { |
| 16 | + global $IP; |
| 17 | + |
| 18 | + $scriptName = @$_SERVER['SCRIPT_NAME']; |
| 19 | + $serverName = @$_SERVER['SERVER_NAME']; |
| 20 | + $documentRoot = @$_SERVER['DOCUMENT_ROOT']; |
| 21 | + |
| 22 | + require( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
| 23 | + # Upload URL hit (to upload.wikimedia.org rather than wiki of origin)... |
| 24 | + if ( $scriptName === '/w/thumb.php' && $serverName === 'upload.wikimedia.org' ) { |
| 25 | + $multiVersion = MWMultiVersion::initializeForUploadWiki( $_SERVER['PATH_INFO'] ); |
| 26 | + # Regular URL hit (wiki of origin)... |
| 27 | + } else { |
| 28 | + $multiVersion = MWMultiVersion::initializeForWiki( $serverName, $documentRoot ); |
| 29 | + } |
| 30 | + |
| 31 | + # Get the MediaWiki version running on this wiki... |
| 32 | + $version = $multiVersion->getVersion(); |
| 33 | + |
| 34 | + # MW_SECURE_HOST set from secure gateway? |
| 35 | + $secure = getenv( 'MW_SECURE_HOST' ); |
| 36 | + $host = $secure ? $secure : $_SERVER['HTTP_HOST']; |
| 37 | + |
| 38 | + # Get the correct MediaWiki path based on this version... |
| 39 | + if ( $host === 'test.wikipedia.org' && !$secure && |
| 40 | + !preg_match( '!thumb\.php!', $_SERVER['REQUEST_URI'] ) ) |
| 41 | + { |
| 42 | + define( 'TESTWIKI', 1 ); |
| 43 | + # Test wiki mostly runs off the version of MediaWiki on /home. |
| 44 | + # As horrible hack for NFS-less image scalers, use regular docroot for thumbs? |
| 45 | + $IP = getHomeMediaWikiDir() . "/$version"; |
| 46 | + } else { |
| 47 | + $IP = getLocalMediaWikiDir() . "/$version"; |
| 48 | + } |
| 49 | + |
| 50 | + chdir( $IP ); |
| 51 | + putenv( "MW_INSTALL_PATH=$IP" ); |
| 52 | + |
| 53 | + return "$IP/$file"; |
| 54 | +} |
| 55 | + |
| 56 | +/** |
| 57 | + * Get the location of the correct version of a MediaWiki CLI |
| 58 | + * entry-point file given the --wiki parameter passed in. |
| 59 | + * |
| 60 | + * This also has some other effects: |
| 61 | + * (a) Sets the $IP global variable (path to MediaWiki) |
| 62 | + * (b) Sets the MW_INSTALL_PATH environmental variable |
| 63 | + * (c) Changes PHP's current directory to the directory of this file. |
| 64 | + * |
| 65 | + * @param string File path (relative to MediaWiki dir) |
| 66 | + * @return string Absolute file path with proper MW location |
| 67 | + */ |
| 68 | +function getMediaWikiCli( $file ) { |
| 69 | + global $IP; |
| 70 | + |
| 71 | + require( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
| 72 | + $multiVersion = MWMultiVersion::initializeForMaintenance(); |
| 73 | + |
| 74 | + # Get the MediaWiki version running on this wiki... |
| 75 | + $version = $multiVersion->getVersion(); |
| 76 | + |
| 77 | + # Get the correct MediaWiki path based on this version... |
| 78 | + if ( $multiVersion->getDatabase() === 'testwiki' ) { |
| 79 | + define( 'TESTWIKI', 1 ); |
| 80 | + $IP = getHomeMediaWikiDir() . "/$version"; |
| 81 | + } else { |
| 82 | + $IP = getLocalMediaWikiDir() . "/$version"; |
| 83 | + } |
| 84 | + |
| 85 | + chdir( $IP ); |
| 86 | + putenv( "MW_INSTALL_PATH=$IP" ); |
| 87 | + |
| 88 | + return "$IP/$file"; |
| 89 | +} |
| 90 | + |
| 91 | +function getLocalMediaWikiDir() { |
| 92 | + return "/usr/local/apache/common"; |
| 93 | +} |
| 94 | + |
| 95 | +function getHomeMediaWikiDir() { |
| 96 | + return "/home/wikipedia/common"; |
| 97 | +} |
Property changes on: trunk/tools/mwmultiversion/multiversion/MWVersion.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 98 | + native |
Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki.php |
— | — | @@ -0,0 +1,125 @@ |
| 2 | +<?php |
| 3 | +if ( php_sapi_name() !== 'cli' ) { |
| 4 | + die( 'This script can only be run from the command line.' ); |
| 5 | +} |
| 6 | + |
| 7 | +error_reporting( E_ALL ); |
| 8 | + |
| 9 | +/** |
| 10 | + * Automatically SVN checkout a MediaWiki version and do some basic wmf setup. |
| 11 | + * LocalSettings.php will be created (which loads CommonSettings.php) and verious |
| 12 | + * symlinks will also be created. |
| 13 | + * |
| 14 | + * The first argument is the SVN directory (relative to mediawiki/branches/wmf). |
| 15 | + * This is typically a version of the format "X.XXwmfX" ("e.g. 1.17wmf1"). |
| 16 | + * The second argument is the target path (relative to /home/wikipedia/common/) |
| 17 | + * to store local copy of the SVN checkout. This is typically of the format "php-X.XX". |
| 18 | + * |
| 19 | + * The script will not run if files already existing in the target directory. |
| 20 | + * Also, assume the user running this script must have an SVN account |
| 21 | + * with the SSH agent/key available. |
| 22 | + * |
| 23 | + * @return void |
| 24 | + */ |
| 25 | +function checkoutMediaWiki() { |
| 26 | + global $argv; |
| 27 | + $commonDir = '/home/wikipedia/common'; |
| 28 | + |
| 29 | + $argsValid = false; |
| 30 | + if ( count( $argv ) >= 3 ) { |
| 31 | + $svnVersion = $argv[1]; // e.g. "X.XXwmfX" |
| 32 | + $dstVersion = $argv[2]; // e.g. "php-X.XX" |
| 33 | + if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $dstVersion, $m ) ) { |
| 34 | + $dstVersionNum = $m[1]; |
| 35 | + $argsValid = true; |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + if ( !$argsValid ) { |
| 40 | + die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX" ); |
| 41 | + } |
| 42 | + |
| 43 | + # The url to SVN to checkout from |
| 44 | + $source = "svn+ssh://svn.wikimedia.org/svnroot/mediawiki/branches/wmf/$svnVersion"; |
| 45 | + |
| 46 | + # Create the destination path to SVN checkout to... |
| 47 | + $destIP = "$commonDir/$dstVersion"; |
| 48 | + if ( file_exists( $destIP ) ) { |
| 49 | + die( "Cannot checkout, the directory $destIP already exists.\n" ); |
| 50 | + } |
| 51 | + print "Creating checkout directory $destIP..."; |
| 52 | + mkdir( $destIP, 0775 ); |
| 53 | + print "done.\n"; |
| 54 | + |
| 55 | + print "Checking out $source to $destIP...\n"; |
| 56 | + # Checkout the SVN directory... |
| 57 | + $retval = 1; // error by default? |
| 58 | + passthru( "svn checkout $source $destIP", $retval ); |
| 59 | + if ( $retval !== 0 ) { |
| 60 | + rmdir( $destIP ); // rollback |
| 61 | + die( "\nUnable to checkout SVN path." ); |
| 62 | + } |
| 63 | + print "...SVN checkout done.\n"; |
| 64 | + |
| 65 | + $localSettingsCode = <<<EOT |
| 66 | +<?php |
| 67 | +# WARNING: This file is publically viewable on the web. Do not put private data here. |
| 68 | +if ( defined('TESTWIKI') ) { |
| 69 | + include_once( "/home/wikipedia/common/wmf-config/CommonSettings.php" ); |
| 70 | +} else { |
| 71 | + include_once( "/apache/common/wmf-config/CommonSettings.php" ); |
| 72 | +} |
| 73 | +EOT; |
| 74 | + |
| 75 | + # Create LocalSettings.php stub... |
| 76 | + $path = "$destIP/LocalSettings.php"; |
| 77 | + if ( !file_exists( $path ) ) { |
| 78 | + if ( file_put_contents( $path, $localSettingsCode ) ) { |
| 79 | + print "Created LocalSettings.php file.\n"; |
| 80 | + } |
| 81 | + } else { |
| 82 | + print "File already exists: $path\n"; |
| 83 | + } |
| 84 | + |
| 85 | + # Create symlink to wmf-config/AdminSettings.php... |
| 86 | + $path = "$destIP/AdminSettings.php"; |
| 87 | + if ( !file_exists( $path ) ) { |
| 88 | + if ( symlink( "../wmf-config/AdminSettings.php", $path ) ) { |
| 89 | + print "Created AdminSettings.php symlink.\n"; |
| 90 | + } |
| 91 | + } else { |
| 92 | + print "File already exists: $path\n"; |
| 93 | + } |
| 94 | + |
| 95 | + # Create symlink to wmf-config/StartProfiler.php... |
| 96 | + $path = "$destIP/StartProfiler.php"; |
| 97 | + if ( !file_exists( $path ) ) { |
| 98 | + if ( symlink( "../wmf-config/StartProfiler.php", $path ) ) { |
| 99 | + print "Created StartProfiler.php symlink.\n"; |
| 100 | + } |
| 101 | + } else { |
| 102 | + print "File already exists: $path\n"; |
| 103 | + } |
| 104 | + |
| 105 | + # Create bits.wikimedia.org symlinks... |
| 106 | + $path = "$commonDir/docroot/bits/skins-$dstVersionNum"; |
| 107 | + if ( !file_exists( $path ) ) { |
| 108 | + if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/skins/", $path ) ) { |
| 109 | + print "Created skins-$dstVersionNum symlink.\n"; |
| 110 | + } |
| 111 | + } else { |
| 112 | + print "File already exists: $path\n"; |
| 113 | + } |
| 114 | + $path = "$commonDir/docroot/bits/w/extensions-$dstVersionNum"; |
| 115 | + if ( !file_exists( $path ) ) { |
| 116 | + if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/extensions", $path ) ) { |
| 117 | + print "Created w/extensions-$dstVersionNum symlink.\n"; |
| 118 | + } |
| 119 | + } else { |
| 120 | + print "File already exists: $path\n"; |
| 121 | + } |
| 122 | + |
| 123 | + print "MediaWiki $dstVersionNum, from $svnVersion, successfully checked out.\n"; |
| 124 | +} |
| 125 | + |
| 126 | +checkoutMediaWiki(); |
Property changes on: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 127 | + native |
Index: trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +<?php |
| 3 | +if ( php_sapi_name() !== 'cli' ) { |
| 4 | + die( 'This script can only be run from the command line.' ); |
| 5 | +} |
| 6 | + |
| 7 | +error_reporting( E_ALL ); |
| 8 | + |
| 9 | +/* |
| 10 | + * Populate wikiversions.cdb file using all the items in all.dblist |
| 11 | + * as keys, each having a value of the specified MediaWiki version. |
| 12 | + * This means that all will be configured to run that version. |
| 13 | + * |
| 14 | + * The first argument is the version, typically of the format "php-X.XX". |
| 15 | + * |
| 16 | + * @return void |
| 17 | + */ |
| 18 | +function populateWikiversionsCDB() { |
| 19 | + global $argv; |
| 20 | + |
| 21 | + $argsValid = false; |
| 22 | + if ( count( $argv ) >= 2 ) { |
| 23 | + $version = $argv[1]; // e.g. "php-X.XX" |
| 24 | + if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $version ) ) { |
| 25 | + $argsValid = true; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + if ( !$argsValid ) { |
| 30 | + die( "Usage: populateWikiVersionsCDB.php php-X.XX" ); |
| 31 | + } |
| 32 | + |
| 33 | + $path = '/home/wikipedia/common/all.dblist'; |
| 34 | + $dbList = explode( "\n", file_get_contents( $path ) ); |
| 35 | + if ( !count( $dbList ) ) { |
| 36 | + die( "Unable to read all.dblist." ); |
| 37 | + } |
| 38 | + |
| 39 | + $wikiVersionList = ''; |
| 40 | + foreach ( $dbList as $dbName ) { |
| 41 | + $wikiVersionList .= "$dbName $version\n"; |
| 42 | + } |
| 43 | + |
| 44 | + $path = '/home/wikipedia/common/wikiversions.cdb'; |
| 45 | + if ( !file_put_contents( $path, $wikiVersionList ) ) { |
| 46 | + die( "Unable to write to wikiversions.cdb." ); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +populateWikiversionsCDB(); |
Property changes on: trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |
Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
— | — | @@ -0,0 +1,221 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Class to handle basic information related to what |
| 5 | + * version of MediaWiki is running on a wiki installation |
| 6 | + */ |
| 7 | +class MWMultiVersion { |
| 8 | + /** |
| 9 | + * @var MWMultiVersion |
| 10 | + */ |
| 11 | + private static $instance; |
| 12 | + /** |
| 13 | + * @var string |
| 14 | + */ |
| 15 | + private $db; |
| 16 | + |
| 17 | + /** |
| 18 | + * To get an inststance of this class, use the statuc helper methods. |
| 19 | + * @see getInstanceForWiki |
| 20 | + * @see getInstanceForUploadWiki |
| 21 | + */ |
| 22 | + private function __construct() {} |
| 23 | + private function __clone() {} |
| 24 | + |
| 25 | + /** |
| 26 | + * Create the version instance |
| 27 | + * @return MWMultiVersion object for this wiki |
| 28 | + */ |
| 29 | + private static function createInstance() { |
| 30 | + if ( isset( self::$instance ) ) { |
| 31 | + die( "MWMultiVersion instance already set!" ); |
| 32 | + } |
| 33 | + self::$instance = new self; |
| 34 | + return self::$instance; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Factory method to get an instance of MWMultiVersion. |
| 39 | + * Use this for all wikis except calls to /w/thumb.php on upload.wikmedia.org. |
| 40 | + * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME'] |
| 41 | + * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT'] |
| 42 | + * @return MWMultiVersion object for this wiki |
| 43 | + */ |
| 44 | + public static function initializeForWiki( $serverName, $docRoot ) { |
| 45 | + $instance = self::createInstance(); |
| 46 | + $instance->setSiteInfoForWiki( $serverName, $docRoot ); |
| 47 | + return $instance; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Factory method to get an instance of MWMultiVersion used |
| 52 | + * for calls to /w/thumb.php on upload.wikmedia.org. |
| 53 | + * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO'] |
| 54 | + * @return MWMultiVersion object for the wiki derived from the pathinfo |
| 55 | + */ |
| 56 | + public static function initializeForUploadWiki( $pathInfo ) { |
| 57 | + $instance = self::createInstance(); |
| 58 | + $instance->setSiteInfoForUploadWiki( $pathInfo ); |
| 59 | + return $instance; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Factory method to get an instance of MWMultiVersion |
| 64 | + * via maintenance scripts since they need to set site and lang. |
| 65 | + * @return MWMultiVersion object for the wiki derived from --wiki CLI parameter |
| 66 | + */ |
| 67 | + public static function initializeForMaintenance() { |
| 68 | + $instance = self::createInstance(); |
| 69 | + $instance->setSiteInfoForMaintenance(); |
| 70 | + return $instance; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get the instance of MWMultiVersion that was previously initialized |
| 75 | + * @return MWMultiVersion|null version object for the wiki |
| 76 | + */ |
| 77 | + public static function getInstance() { |
| 78 | + return self::$instance; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Derives site and lang from the parameters and sets $site and $lang on the instance |
| 83 | + * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME'] |
| 84 | + * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT'] |
| 85 | + * @return void |
| 86 | + */ |
| 87 | + private function setSiteInfoForWiki( $serverName, $docRoot ) { |
| 88 | + $secure = getenv( 'MW_SECURE_HOST' ); |
| 89 | + $matches = array(); |
| 90 | + if ( $secure ) { |
| 91 | + if ( !preg_match('/^([^.]+)\.([^.]+)\./', $secure, $matches ) ) { |
| 92 | + die( "invalid hostname" ); |
| 93 | + } |
| 94 | + $lang = $matches[1]; |
| 95 | + $site = $matches[2]; |
| 96 | + |
| 97 | + // @TODO: move/use some special case dblist? |
| 98 | + $idioSyncratics = array( "commons", "grants", "sources", "wikimania", |
| 99 | + "wikimania2006", "foundation", "meta" ); |
| 100 | + if ( in_array( $lang, $idioSyncratics ) ) { |
| 101 | + $site = "wikipedia"; |
| 102 | + } |
| 103 | + } else { |
| 104 | + $site = "wikipedia"; |
| 105 | + if ( preg_match( '/^(?:\/usr\/local\/apache\/|\/home\/wikipedia\/)(?:htdocs|common\/docroot)\/([a-z]+)\.org/', $docRoot, $matches ) ) { |
| 106 | + $site = $matches[1]; |
| 107 | + if ( preg_match( '/^(.*)\.' . preg_quote( $site ) . '\.org$/', $serverName, $matches ) ) { |
| 108 | + $lang = $matches[1]; |
| 109 | + // For some special subdomains, like pa.us |
| 110 | + $lang = str_replace( '.', '-', $lang ); |
| 111 | + } else if ( preg_match( '/^(.*)\.prototype\.wikimedia\.org$/', $serverName, $matches ) ) { |
| 112 | + $lang = $matches[1]; |
| 113 | + } else { |
| 114 | + die( "Invalid host name ($serverName), can't determine language" ); |
| 115 | + } |
| 116 | + } elseif ( preg_match( "/^\/usr\/local\/apache\/(?:htdocs|common\/docroot)\/([a-z0-9\-_]*)$/", $docRoot, $matches ) ) { |
| 117 | + $site = "wikipedia"; |
| 118 | + $lang = $matches[1]; |
| 119 | + } else { |
| 120 | + die( "Invalid host name (docroot=" . $docRoot . "), can't determine language." ); |
| 121 | + } |
| 122 | + } |
| 123 | + $this->loadDBFromSite( $site, $lang ); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Derives site and lang from the parameter and sets $site and $lang on the instance |
| 128 | + * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO'] |
| 129 | + * @return void |
| 130 | + */ |
| 131 | + private function setSiteInfoForUploadWiki( $pathInfo ) { |
| 132 | + $pathBits = explode( '/', $pathInfo ); |
| 133 | + if ( count( $pathBits ) < 3 ) { |
| 134 | + die( "Invalid file path info (pathinfo=" . $pathInfo . "), can't determine language." ); |
| 135 | + } |
| 136 | + $site = $pathBits[1]; |
| 137 | + $lang = $pathBits[2]; |
| 138 | + $this->loadDBFromSite( $site, $lang ); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Gets the site and lang from the --wiki argument. |
| 143 | + * This code reflects how Maintenance.php reads arguments. |
| 144 | + * @return void |
| 145 | + */ |
| 146 | + private function setSiteInfoForMaintenance() { |
| 147 | + global $argv; |
| 148 | + |
| 149 | + $dbname = ''; |
| 150 | + # The --wiki param must the second argument to to avoid |
| 151 | + # any "options with args" ambiguity (see Maintenance.php). |
| 152 | + if ( substr( $argv[1], 0, 7 ) === '--wiki=' ) { |
| 153 | + $dbname = substr( $argv[1], 7 ); |
| 154 | + } elseif ( $argv[0] === 'addwiki.php' ) { |
| 155 | + # Most scripts assume that the wiki already exists. addwiki.php is |
| 156 | + # obviously an exception. Go ahead and assumme aawiki as normal. |
| 157 | + $dbname = 'aawiki'; |
| 158 | + $argv = array_merge( array( $argv[0], "--wiki=$dbname" ), array_slice( $argv, 1 ) ); |
| 159 | + } |
| 160 | + |
| 161 | + if ( $dbname === '' ) { |
| 162 | + die( "--wiki must be the first parameter." ); |
| 163 | + } |
| 164 | + |
| 165 | + $this->db = $dbname; |
| 166 | + putenv( 'MW_DBNAME=' . $dbname ); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Load the DB from the site and lang for this wiki |
| 171 | + * @param $site string |
| 172 | + * @param $lang string |
| 173 | + * @return void |
| 174 | + */ |
| 175 | + private function loadDBFromSite( $site, $lang ) { |
| 176 | + if ( $site == "wikipedia" ) { |
| 177 | + $dbSuffix = "wiki"; |
| 178 | + } else { |
| 179 | + $dbSuffix = $site; |
| 180 | + } |
| 181 | + $this->db = str_replace( "-", "_", $lang . $dbSuffix ); |
| 182 | + putenv( 'MW_DBNAME=' . $this->db ); |
| 183 | + } |
| 184 | + |
| 185 | + /** |
| 186 | + * Get the DB name for this wiki |
| 187 | + * @return String the database name |
| 188 | + */ |
| 189 | + public function getDatabase() { |
| 190 | + return $this->db; |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Get the version as specified in a cdb file located |
| 195 | + * at /usr/local/apache/common/wikiversions.cdb. |
| 196 | + * The key should be the dbname and the version should be the version directory. |
| 197 | + * @return String the version directory for this wiki |
| 198 | + */ |
| 199 | + public function getVersion() { |
| 200 | + $db = dba_open( '/usr/local/apache/common/wikiversions.cdb', 'r', 'cdb' ); |
| 201 | + if ( $db ) { |
| 202 | + $version = dba_fetch( $this->getDatabase(), $db ); |
| 203 | + if ( strpos( $version, 'php-' ) !== 0 ) { |
| 204 | + die( 'wikiversions.cdb entry should be of the format: php-...' ); |
| 205 | + } |
| 206 | + } else { |
| 207 | + //trigger_error( "Unable to open /usr/local/apache/common/wikiversions.cdb. Assuming php-1.17", E_USER_ERROR ); |
| 208 | + $version = 'php-1.17'; |
| 209 | + } |
| 210 | + return $version; |
| 211 | + } |
| 212 | + |
| 213 | + /** |
| 214 | + * Get the version number as specified in a cdb file located |
| 215 | + * at /usr/local/apache/common/wikiversions.cdb. |
| 216 | + * @return String the version number for this wiki (e.g. "x.xx" or "trunk") |
| 217 | + */ |
| 218 | + public function getVersionNumber() { |
| 219 | + list( /*...*/, $ver ) = explode( $this->getVersion(), '-', 2 ); |
| 220 | + return $ver; |
| 221 | + } |
| 222 | +} |
Property changes on: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 223 | + native |
Index: trunk/tools/mwmultiversion/multiversion/MWScript.php |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +<?php |
| 3 | +if ( php_sapi_name() !== 'cli' ) { |
| 4 | + exit; // sanity, script run via CLI |
| 5 | +} |
| 6 | + |
| 7 | +error_reporting( E_ALL ); |
| 8 | + |
| 9 | +/** |
| 10 | + * Run a MediaWiki script based on the parameters (like --wiki) given to CLI. |
| 11 | + * |
| 12 | + * The first argument must be the relative (to MediaWiki) script file path. |
| 13 | + * If only a filename is given, it will be assumed to reside in /maintenance. |
| 14 | + * The second argument must be the --wiki parameter. This is to avoid |
| 15 | + * any "options with args" ambiguity (see Maintenance.php). |
| 16 | + * |
| 17 | + * When the actual script is run, $argv[0] (this file's name) will be not be kept. |
| 18 | + * Also, $argv[1] (the script path) will be changed to the script file name. |
| 19 | + * All other arguments will be preserved. |
| 20 | + * |
| 21 | + * @return void |
| 22 | + */ |
| 23 | +function runMWScript() { |
| 24 | + global $argv; |
| 25 | + if ( count( $argv ) < 2 ) { |
| 26 | + die( "The MediaWiki script file path must be the first argument." ); |
| 27 | + } |
| 28 | + |
| 29 | + $relFile = $argv[1]; // the script file to run |
| 30 | + # If no MW directory is given then assume this is a /maintenance script |
| 31 | + if ( strpos( $relFile, '/' ) === false ) { |
| 32 | + $relFile = "maintenance/$relFile"; // convenience |
| 33 | + } |
| 34 | + |
| 35 | + # Remove effects of this wrapper from $argv... |
| 36 | + array_shift( $argv ); // remove this file's name from args |
| 37 | + # Code stolen from wfBasename() in GlobalFunctions.php :) |
| 38 | + if ( preg_match( "#([^/\\\\]*?)[/\\\\]*$#", $argv[0], $matches ) ) { |
| 39 | + $argv[0] = $matches[1]; // make first arg the script file name |
| 40 | + } |
| 41 | + |
| 42 | + # MWScript.php should be in common/ |
| 43 | + require_once( dirname( __FILE__ ) . '/../wmf-config/MWVersion.php' ); |
| 44 | + $file = getMediaWikiCli( $relFile ); |
| 45 | + if ( !file_exists( $file ) ) { |
| 46 | + die( "The MediaWiki script file \"{$file}\" does not exist." ); |
| 47 | + } |
| 48 | + |
| 49 | + # Run the script! (for HipHip, we will need to shell out here) |
| 50 | + require_once( $file ); |
| 51 | +} |
| 52 | + |
| 53 | +runMWScript(); |
Property changes on: trunk/tools/mwmultiversion/multiversion/MWScript.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 54 | + native |
Index: trunk/tools/mwmultiversion/wmf-config/MWMultiVersion.php |
— | — | @@ -1,221 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Class to handle basic information related to what |
5 | | - * version of MediaWiki is running on a wiki installation |
6 | | - */ |
7 | | -class MWMultiVersion { |
8 | | - /** |
9 | | - * @var MWMultiVersion |
10 | | - */ |
11 | | - private static $instance; |
12 | | - /** |
13 | | - * @var string |
14 | | - */ |
15 | | - private $db; |
16 | | - |
17 | | - /** |
18 | | - * To get an inststance of this class, use the statuc helper methods. |
19 | | - * @see getInstanceForWiki |
20 | | - * @see getInstanceForUploadWiki |
21 | | - */ |
22 | | - private function __construct() {} |
23 | | - private function __clone() {} |
24 | | - |
25 | | - /** |
26 | | - * Create the version instance |
27 | | - * @return MWMultiVersion object for this wiki |
28 | | - */ |
29 | | - private static function createInstance() { |
30 | | - if ( isset( self::$instance ) ) { |
31 | | - die( "MWMultiVersion instance already set!" ); |
32 | | - } |
33 | | - self::$instance = new self; |
34 | | - return self::$instance; |
35 | | - } |
36 | | - |
37 | | - /** |
38 | | - * Factory method to get an instance of MWMultiVersion. |
39 | | - * Use this for all wikis except calls to /w/thumb.php on upload.wikmedia.org. |
40 | | - * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME'] |
41 | | - * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT'] |
42 | | - * @return MWMultiVersion object for this wiki |
43 | | - */ |
44 | | - public static function initializeForWiki( $serverName, $docRoot ) { |
45 | | - $instance = self::createInstance(); |
46 | | - $instance->setSiteInfoForWiki( $serverName, $docRoot ); |
47 | | - return $instance; |
48 | | - } |
49 | | - |
50 | | - /** |
51 | | - * Factory method to get an instance of MWMultiVersion used |
52 | | - * for calls to /w/thumb.php on upload.wikmedia.org. |
53 | | - * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO'] |
54 | | - * @return MWMultiVersion object for the wiki derived from the pathinfo |
55 | | - */ |
56 | | - public static function initializeForUploadWiki( $pathInfo ) { |
57 | | - $instance = self::createInstance(); |
58 | | - $instance->setSiteInfoForUploadWiki( $pathInfo ); |
59 | | - return $instance; |
60 | | - } |
61 | | - |
62 | | - /** |
63 | | - * Factory method to get an instance of MWMultiVersion |
64 | | - * via maintenance scripts since they need to set site and lang. |
65 | | - * @return MWMultiVersion object for the wiki derived from --wiki CLI parameter |
66 | | - */ |
67 | | - public static function initializeForMaintenance() { |
68 | | - $instance = self::createInstance(); |
69 | | - $instance->setSiteInfoForMaintenance(); |
70 | | - return $instance; |
71 | | - } |
72 | | - |
73 | | - /** |
74 | | - * Get the instance of MWMultiVersion that was previously initialized |
75 | | - * @return MWMultiVersion|null version object for the wiki |
76 | | - */ |
77 | | - public static function getInstance() { |
78 | | - return self::$instance; |
79 | | - } |
80 | | - |
81 | | - /** |
82 | | - * Derives site and lang from the parameters and sets $site and $lang on the instance |
83 | | - * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME'] |
84 | | - * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT'] |
85 | | - * @return void |
86 | | - */ |
87 | | - private function setSiteInfoForWiki( $serverName, $docRoot ) { |
88 | | - $secure = getenv( 'MW_SECURE_HOST' ); |
89 | | - $matches = array(); |
90 | | - if ( $secure ) { |
91 | | - if ( !preg_match('/^([^.]+)\.([^.]+)\./', $secure, $matches ) ) { |
92 | | - die( "invalid hostname" ); |
93 | | - } |
94 | | - $lang = $matches[1]; |
95 | | - $site = $matches[2]; |
96 | | - |
97 | | - // @TODO: move/use some special case dblist? |
98 | | - $idioSyncratics = array( "commons", "grants", "sources", "wikimania", |
99 | | - "wikimania2006", "foundation", "meta" ); |
100 | | - if ( in_array( $lang, $idioSyncratics ) ) { |
101 | | - $site = "wikipedia"; |
102 | | - } |
103 | | - } else { |
104 | | - $site = "wikipedia"; |
105 | | - if ( preg_match( '/^(?:\/usr\/local\/apache\/|\/home\/wikipedia\/)(?:htdocs|common\/docroot)\/([a-z]+)\.org/', $docRoot, $matches ) ) { |
106 | | - $site = $matches[1]; |
107 | | - if ( preg_match( '/^(.*)\.' . preg_quote( $site ) . '\.org$/', $serverName, $matches ) ) { |
108 | | - $lang = $matches[1]; |
109 | | - // For some special subdomains, like pa.us |
110 | | - $lang = str_replace( '.', '-', $lang ); |
111 | | - } else if ( preg_match( '/^(.*)\.prototype\.wikimedia\.org$/', $serverName, $matches ) ) { |
112 | | - $lang = $matches[1]; |
113 | | - } else { |
114 | | - die( "Invalid host name ($serverName), can't determine language" ); |
115 | | - } |
116 | | - } elseif ( preg_match( "/^\/usr\/local\/apache\/(?:htdocs|common\/docroot)\/([a-z0-9\-_]*)$/", $docRoot, $matches ) ) { |
117 | | - $site = "wikipedia"; |
118 | | - $lang = $matches[1]; |
119 | | - } else { |
120 | | - die( "Invalid host name (docroot=" . $docRoot . "), can't determine language." ); |
121 | | - } |
122 | | - } |
123 | | - $this->loadDBFromSite( $site, $lang ); |
124 | | - } |
125 | | - |
126 | | - /** |
127 | | - * Derives site and lang from the parameter and sets $site and $lang on the instance |
128 | | - * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO'] |
129 | | - * @return void |
130 | | - */ |
131 | | - private function setSiteInfoForUploadWiki( $pathInfo ) { |
132 | | - $pathBits = explode( '/', $pathInfo ); |
133 | | - if ( count( $pathBits ) < 3 ) { |
134 | | - die( "Invalid file path info (pathinfo=" . $pathInfo . "), can't determine language." ); |
135 | | - } |
136 | | - $site = $pathBits[1]; |
137 | | - $lang = $pathBits[2]; |
138 | | - $this->loadDBFromSite( $site, $lang ); |
139 | | - } |
140 | | - |
141 | | - /** |
142 | | - * Gets the site and lang from the --wiki argument. |
143 | | - * This code reflects how Maintenance.php reads arguments. |
144 | | - * @return void |
145 | | - */ |
146 | | - private function setSiteInfoForMaintenance() { |
147 | | - global $argv; |
148 | | - |
149 | | - $dbname = ''; |
150 | | - # The --wiki param must the second argument to to avoid |
151 | | - # any "options with args" ambiguity (see Maintenance.php). |
152 | | - if ( substr( $argv[1], 0, 7 ) === '--wiki=' ) { |
153 | | - $dbname = substr( $argv[1], 7 ); |
154 | | - } elseif ( $argv[0] === 'addwiki.php' ) { |
155 | | - # Most scripts assume that the wiki already exists. addwiki.php is |
156 | | - # obviously an exception. Go ahead and assumme aawiki as normal. |
157 | | - $dbname = 'aawiki'; |
158 | | - $argv = array_merge( array( $argv[0], "--wiki=$dbname" ), array_slice( $argv, 1 ) ); |
159 | | - } |
160 | | - |
161 | | - if ( $dbname === '' ) { |
162 | | - die( "--wiki must be the first parameter." ); |
163 | | - } |
164 | | - |
165 | | - $this->db = $dbname; |
166 | | - putenv( 'MW_DBNAME=' . $dbname ); |
167 | | - } |
168 | | - |
169 | | - /** |
170 | | - * Load the DB from the site and lang for this wiki |
171 | | - * @param $site string |
172 | | - * @param $lang string |
173 | | - * @return void |
174 | | - */ |
175 | | - private function loadDBFromSite( $site, $lang ) { |
176 | | - if ( $site == "wikipedia" ) { |
177 | | - $dbSuffix = "wiki"; |
178 | | - } else { |
179 | | - $dbSuffix = $site; |
180 | | - } |
181 | | - $this->db = str_replace( "-", "_", $lang . $dbSuffix ); |
182 | | - putenv( 'MW_DBNAME=' . $this->db ); |
183 | | - } |
184 | | - |
185 | | - /** |
186 | | - * Get the DB name for this wiki |
187 | | - * @return String the database name |
188 | | - */ |
189 | | - public function getDatabase() { |
190 | | - return $this->db; |
191 | | - } |
192 | | - |
193 | | - /** |
194 | | - * Get the version as specified in a cdb file located |
195 | | - * at /usr/local/apache/common/wikiversions.cdb. |
196 | | - * The key should be the dbname and the version should be the version directory. |
197 | | - * @return String the version directory for this wiki |
198 | | - */ |
199 | | - public function getVersion() { |
200 | | - $db = dba_open( '/usr/local/apache/common/wikiversions.cdb', 'r', 'cdb' ); |
201 | | - if ( $db ) { |
202 | | - $version = dba_fetch( $this->getDatabase(), $db ); |
203 | | - if ( strpos( $version, 'php-' ) !== 0 ) { |
204 | | - die( 'wikiversions.cdb entry should be of the format: php-...' ); |
205 | | - } |
206 | | - } else { |
207 | | - //trigger_error( "Unable to open /usr/local/apache/common/wikiversions.cdb. Assuming php-1.17", E_USER_ERROR ); |
208 | | - $version = 'php-1.17'; |
209 | | - } |
210 | | - return $version; |
211 | | - } |
212 | | - |
213 | | - /** |
214 | | - * Get the version number as specified in a cdb file located |
215 | | - * at /usr/local/apache/common/wikiversions.cdb. |
216 | | - * @return String the version number for this wiki (e.g. "x.xx" or "trunk") |
217 | | - */ |
218 | | - public function getVersionNumber() { |
219 | | - list( /*...*/, $ver ) = explode( $this->getVersion(), '-', 2 ); |
220 | | - return $ver; |
221 | | - } |
222 | | -} |
Index: trunk/tools/mwmultiversion/wmf-config/CommonSettings.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | # Initialisation |
45 | 45 | |
46 | 46 | # Get the version object for this Wiki (must be set by now, along with $IP) |
47 | | -require_once( dirname( __FILE__ ) . "/MWMultiVersion.php" ); |
| 47 | +require_once( dirname( __FILE__ ) . "/../multiversion/MWMultiVersion.php" ); |
48 | 48 | $multiVersion = MWMultiVersion::getInstance(); |
49 | 49 | /* |
50 | 50 | if ( !$multiVersion ) { |