r93513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93512‎ | r93513 | r93514 >
Date:05:17, 30 July 2011
Author:aaron
Status:ok
Tags:
Comment:
* Added a switchAllMediaWikis script to switch all wikis running one version to another
* Dummy-proofed populateWikiversionsCDB and updated MW version validation
* Fixed "Usage:" help text in some places
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/populateWikiversions (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis (added) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/populateWikiversions
@@ -7,6 +7,7 @@
88 * This means that all will be configured to run that version.
99 *
1010 * The first argument is the version, typically of the format "php-X.XX".
 11+ * The second argument is a confirmation ("confirm").
1112 *
1213 * @return void
1314 */
@@ -15,9 +16,9 @@
1617 $common = '/home/wikipedia/common';
1718
1819 $argsValid = false;
19 - if ( count( $argv ) >= 2 ) {
 20+ if ( count( $argv ) >= 3 && $argv[2] === 'confirm' ) {
2021 $version = $argv[1]; // e.g. "php-X.XX"
21 - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $version ) ) {
 22+ if ( preg_match( '/^php-(?:\d+\.\d+|trunk)(?:-\d)?$/', $version ) ) {
2223 $argsValid = true;
2324 }
2425 }
Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki
@@ -32,7 +32,7 @@
3333 }
3434
3535 if ( !$argsValid ) {
36 - die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX\n" );
 36+ die( "Usage: checkoutMediaWiki X.XXwmfX php-X.XX\n" );
3737 }
3838
3939 # The url to SVN to checkout from
Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis
@@ -0,0 +1,64 @@
 2+#!/usr/bin/env php
 3+<?php
 4+error_reporting( E_ALL );
 5+/*
 6+ * This script switches all wikis running one version to another version.
 7+ * It merely changes the wikiversions.dat and wikiversions.cdb files on /home,
 8+ * so they will still need to be synced to push the upgrade/downgrade.
 9+ *
 10+ * The first argument is the old version, typically of the format "php-X.XX".
 11+ * If "all" is given, then all wikis will be switched over.
 12+ * The second argument is the new version, typically of the format "php-X.XX".
 13+ *
 14+ * @return void
 15+ */
 16+function switchAllMediaWikis() {
 17+ global $argv;
 18+ $common = '/home/wikipedia/common';
 19+
 20+ $argsValid = false;
 21+ if ( count( $argv ) >= 3 ) {
 22+ $oldVersion = $argv[1]; // e.g. "php-X.XX"
 23+ $newVersion = $argv[2]; // e.g. "php-X.XX"
 24+ if ( preg_match( '/^php-(?:\d+\.\d+|trunk)(?:-\d)?$/', $newVersion ) ) {
 25+ $argsValid = true;
 26+ }
 27+ }
 28+
 29+ if ( !$argsValid ) {
 30+ die( "Usage: upgradeMediaWikis php-X.XX php-X.XX\n" );
 31+ }
 32+
 33+ $path = "$common/wikiversions.dat";
 34+ $verList = array_filter( explode( "\n", file_get_contents( $path ) ) );
 35+ if ( !count( $verList ) ) {
 36+ die( "Unable to read wikiversions.dat.\n" );
 37+ }
 38+
 39+ $datList = "";
 40+ foreach ( $verList as $item ) {
 41+ $items = explode( ' ', $row );
 42+ # Existing values...
 43+ $dbName = $items[0];
 44+ $version = $items[1];
 45+ $extVersion = isset( $items[2] ) ? $items[2] : '';
 46+ # Update this wiki?
 47+ if ( $version === $oldVersion || $oldVersion === 'all' ) {
 48+ $version = $newVersion; // switch!
 49+ }
 50+ if ( $extVersion !== '' ) {
 51+ $datList .= "{$dbName} {$version} {$extVersion}\n";
 52+ } else {
 53+ $datList .= "{$dbName} {$version}\n";
 54+ }
 55+ }
 56+
 57+ # Create wikiversions.dat...
 58+ if ( !file_put_contents( $path, $datList ) ) {
 59+ die( "Unable to write to wikiversions.dat.\n" );
 60+ }
 61+ # Rebuild wikiversions.cdb...
 62+ shell_exec( "cd $common/multiversion && ./refreshWikiversionsCDB" );
 63+}
 64+
 65+switchAllMediaWikis();
Property changes on: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis
___________________________________________________________________
Added: svn:executable
166 + *

Status & tagging log