r92799 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92798‎ | r92799 | r92800 >
Date:21:43, 21 July 2011
Author:aaron
Status:ok
Tags:
Comment:
* Added newlines to die() statements
* Improved "needs to be cli" error handling
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWScript.php (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki.php (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( php_sapi_name() !== 'cli' ) {
4 - die( 'This script can only be run from the command line.' );
 4+ die( "This script can only be run from the command line.\n" );
55 }
66
77 error_reporting( E_ALL );
@@ -36,7 +36,7 @@
3737 }
3838
3939 if ( !$argsValid ) {
40 - die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX" );
 40+ die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX\n" );
4141 }
4242
4343 # The url to SVN to checkout from
@@ -57,7 +57,7 @@
5858 passthru( "svn checkout $source $destIP", $retval );
5959 if ( $retval !== 0 ) {
6060 rmdir( $destIP ); // rollback
61 - die( "\nUnable to checkout SVN path." );
 61+ die( "\nUnable to checkout SVN path.\n" );
6262 }
6363 print "...SVN checkout done.\n";
6464
Index: trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( php_sapi_name() !== 'cli' ) {
4 - die( 'This script can only be run from the command line.' );
 4+ die( "This script can only be run from the command line.\n" );
55 }
66
77 error_reporting( E_ALL );
@@ -26,7 +26,7 @@
2727 }
2828
2929 if ( !$argsValid ) {
30 - die( "Usage: populateWikiVersionsCDB.php php-X.XX" );
 30+ die( "Usage: populateWikiVersionsCDB.php php-X.XX\n" );
3131 }
3232
3333 $path = '/home/wikipedia/common/all.dblist';
@@ -42,7 +42,7 @@
4343
4444 $path = '/home/wikipedia/common/wikiversions.cdb';
4545 if ( !file_put_contents( $path, $wikiVersionList ) ) {
46 - die( "Unable to write to wikiversions.cdb." );
 46+ die( "Unable to write to wikiversions.cdb.\n" );
4747 }
4848 }
4949
Index: trunk/tools/mwmultiversion/multiversion/MWScript.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( php_sapi_name() !== 'cli' ) {
4 - exit; // sanity, script run via CLI
 4+ die( "This script can only be run from the command line.\n" );
55 }
66
77 error_reporting( E_ALL );
@@ -22,7 +22,7 @@
2323 function runMWScript() {
2424 global $argv;
2525 if ( count( $argv ) < 2 ) {
26 - die( "The MediaWiki script file path must be the first argument." );
 26+ die( "The MediaWiki script file path must be the first argument.\n" );
2727 }
2828
2929 $relFile = $argv[1]; // the script file to run
@@ -42,7 +42,7 @@
4343 require_once( dirname( __FILE__ ) . '/../wmf-config/MWVersion.php' );
4444 $file = getMediaWikiCli( $relFile );
4545 if ( !file_exists( $file ) ) {
46 - die( "The MediaWiki script file \"{$file}\" does not exist." );
 46+ die( "The MediaWiki script file \"{$file}\" does not exist.\n" );
4747 }
4848
4949 # Run the script! (for HipHip, we will need to shell out here)

Status & tagging log