r12660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12659‎ | r12660 | r12661 >
Date:02:49, 14 January 2006
Author:vibber
Status:old
Tags:
Comment:
* Added wfDie() wrapper, and some manual die(-1), to force the return code
to the shell to return nonzero when we crap out with an error.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/img_auth.php (modified) (history)
  • /trunk/phase3/includes/BagOStuff.php (modified) (history)
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)
  • /trunk/phase3/includes/Categoryfinder.php (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/DatabasePostgreSQL.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Exif.php (modified) (history)
  • /trunk/phase3/includes/Export.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/HistoryBlob.php (modified) (history)
  • /trunk/phase3/includes/Hooks.php (modified) (history)
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/ObjectCache.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/PersistentObject.php (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinPHPTal.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/compatability/ctype.php (modified) (history)
  • /trunk/phase3/includes/normal/UtfNormalUtil.php (modified) (history)
  • /trunk/phase3/includes/proxy_check.php (modified) (history)
  • /trunk/phase3/includes/templates/Confirmemail.php (modified) (history)
  • /trunk/phase3/includes/templates/Userlogin.php (modified) (history)
  • /trunk/phase3/install-utils.inc (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/maintenance/InitialiseMessages.inc (modified) (history)
  • /trunk/phase3/maintenance/addwiki.php (modified) (history)
  • /trunk/phase3/maintenance/backup.inc (modified) (history)
  • /trunk/phase3/maintenance/benchmarkPurge.php (modified) (history)
  • /trunk/phase3/maintenance/changePassword.php (modified) (history)
  • /trunk/phase3/maintenance/cleanupTitles.php (modified) (history)
  • /trunk/phase3/maintenance/commandLine.inc (modified) (history)
  • /trunk/phase3/maintenance/diffLanguage.php (modified) (history)
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)
  • /trunk/phase3/maintenance/importDump.php (modified) (history)
  • /trunk/phase3/maintenance/importUseModWiki.php (modified) (history)
  • /trunk/phase3/maintenance/lang2po.php (modified) (history)
  • /trunk/phase3/maintenance/langmemusage.php (modified) (history)
  • /trunk/phase3/maintenance/mwdocgen.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)
  • /trunk/phase3/maintenance/parserTestsParserHook.php (modified) (history)
  • /trunk/phase3/maintenance/parserTestsParserTime.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildInterwiki.inc (modified) (history)
  • /trunk/phase3/maintenance/removeUnusedAccounts.php (modified) (history)
  • /trunk/phase3/maintenance/storage/compressOld.php (modified) (history)
  • /trunk/phase3/maintenance/transstat.php (modified) (history)
  • /trunk/phase3/maintenance/updateSpecialPages.php (modified) (history)
  • /trunk/phase3/profileinfo.php (modified) (history)
  • /trunk/phase3/redirect.php (modified) (history)
  • /trunk/phase3/skins/Chick.php (modified) (history)
  • /trunk/phase3/skins/CologneBlue.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/MySkin.php (modified) (history)
  • /trunk/phase3/skins/Nostalgia.php (modified) (history)
  • /trunk/phase3/skins/Simple.php (modified) (history)
  • /trunk/phase3/skins/Standard.php (modified) (history)
  • /trunk/phase3/skins/disabled/Amethyst.php (modified) (history)
  • /trunk/phase3/skins/disabled/Chick.php (modified) (history)
  • /trunk/phase3/skins/disabled/HTMLDump.php (modified) (history)
  • /trunk/phase3/skins/disabled/MonoBookTal.php (modified) (history)
  • /trunk/phase3/skins/disabled/WikimediaWiki.php (modified) (history)
  • /trunk/phase3/tests/RunTests.php (modified) (history)
  • /trunk/phase3/thumb.php (modified) (history)
  • /trunk/phase3/trackback.php (modified) (history)

Diff [purge]

Index: trunk/phase3/install-utils.inc
@@ -7,10 +7,12 @@
88
99 if( !function_exists( 'version_compare' ) ) {
1010 # version_compare was introduced in 4.1.0
11 - die( "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is required. ABORTING.\n" );
 11+ echo "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is required. ABORTING.\n";
 12+ die( -1 );
1213 }
1314 if( version_compare( phpversion(), '4.3.2' ) < 0 ) {
14 - die( "PHP 4.3.2 or higher is required. ABORTING.\n" );
 15+ echo "PHP 4.3.2 or higher is required. ABORTING.\n";
 16+ die( -1 );
1517 }
1618
1719 if (!extension_loaded('mysql')) {
Index: trunk/phase3/maintenance/changePassword.php
@@ -40,7 +40,7 @@
4141 require_once 'commandLine.inc';
4242
4343 if( in_array( '--help', $argv ) )
44 - die(
 44+ wfDie(
4545 "Usage: php changePassword.php [--user=user --password=password | --help]\n" .
4646 "\toptions:\n" .
4747 "\t\t--help\tshow this message\n" .
Index: trunk/phase3/maintenance/removeUnusedAccounts.php
@@ -18,7 +18,7 @@
1919 # Check parameters
2020 if( @$options['help'] ) {
2121 echo( "USAGE: removeUnusedAccounts.php [--help|--delete]\n\nThe first (default) account is ignored.\n\n" );
22 - die();
 22+ wfDie();
2323 } else {
2424 $delete = @$options['delete'] ? true : false ;
2525 }
Index: trunk/phase3/maintenance/backup.inc
@@ -103,7 +103,7 @@
104104 $sinks[] = $sink;
105105 }
106106 if( !isset( $this->outputTypes[$val] ) ) {
107 - die( "Unrecognized output sink type '$val'\n" );
 107+ wfDie( "Unrecognized output sink type '$val'\n" );
108108 }
109109 $type = $this->outputTypes[$val];
110110 $sink = new $type( $param );
@@ -114,7 +114,7 @@
115115 $sink = new DumpOutput();
116116 }
117117 if( !isset( $this->filterTypes[$val] ) ) {
118 - die( "Unrecognized filter type '$val'\n" );
 118+ wfDie( "Unrecognized filter type '$val'\n" );
119119 }
120120 $type = $this->filterTypes[$val];
121121 $filter = new $type( $sink, $param );
Index: trunk/phase3/maintenance/importDump.php
@@ -112,7 +112,7 @@
113113 }
114114
115115 if( wfReadOnly() ) {
116 - die( "Wiki is in read-only mode; you'll need to disable it for import to work.\n" );
 116+ wfDie( "Wiki is in read-only mode; you'll need to disable it for import to work.\n" );
117117 }
118118
119119 $reader = new BackupReader();
Index: trunk/phase3/maintenance/updateSpecialPages.php
@@ -13,7 +13,7 @@
1414 print " --help : this help message\n";
1515 print " --list : list special pages names\n";
1616 print " --only=page : only update 'page'. Ex: --only=BrokenRedirects\n";
17 - die();
 17+ wfDie();
1818 }
1919
2020 $wgOut->disable();
Index: trunk/phase3/maintenance/InitialiseMessages.inc
@@ -39,7 +39,7 @@
4040 foreach ($variants as $v) {
4141 $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) );
4242 if( !class_exists($langclass) ) {
43 - die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?");
 43+ wfDie( "class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?" );
4444 }
4545 $lang = new $langclass;
4646
Index: trunk/phase3/maintenance/importUseModWiki.php
@@ -27,7 +27,8 @@
2828 */
2929
3030 if( php_sapi_name() != 'cli' ) {
31 - die( "Please customize the settings and run me from the command line." );
 31+ echo "Please customize the settings and run me from the command line.";
 32+ die( -1 );
3233 }
3334
3435 /** Set these correctly! */
@@ -124,7 +125,8 @@
125126
126127 $fname = $wgRootDirectory . "/page/" . useModFilename( $title ) . ".db";
127128 if( !file_exists( $fname ) ) {
128 - die( "Couldn't open file '$fname' for page '$title'.\n" );
 129+ echo "Couldn't open file '$fname' for page '$title'.\n";
 130+ die( -1 );
129131 }
130132
131133 $page = splitHash( $FS1, file_get_contents( $fname ) );
Index: trunk/phase3/maintenance/diffLanguage.php
@@ -43,7 +43,7 @@
4444 require_once( 'parserTests.inc' );
4545 require_once( 'commandLine.inc' );
4646
47 -if( isset($options['help']) ) { usage(); die(); }
 47+if( isset($options['help']) ) { usage(); wfDie(); }
4848
4949 $wgLanguageCode = ucfirstlcrest($wgLanguageCode);
5050 /** Language messages we will use as reference. By default 'en' */
@@ -85,7 +85,7 @@
8686 print "Including $langFile\n";
8787 global $wgNamespaceNamesEn;
8888 include($langFile);
89 - } else die("ERROR: The file $langFile does not exist !\n");
 89+ } else wfDie("ERROR: The file $langFile does not exist !\n");
9090 }
9191 return $$foo;
9292 }
@@ -124,7 +124,7 @@
125125 $testLanguage = $lang;
126126 } else {
127127 usage();
128 - die();
 128+ wfDie();
129129 }
130130
131131 /** parsertest is used to do differences */
Index: trunk/phase3/maintenance/cleanupTitles.php
@@ -177,7 +177,7 @@
178178 $title = $verified;
179179 }
180180 if( is_null( $title ) ) {
181 - die( "Something awry; empty title.\n" );
 181+ wfDie( "Something awry; empty title.\n" );
182182 }
183183 $ns = $title->getNamespace();
184184 $dest = $title->getDbKey();
Index: trunk/phase3/maintenance/parserTestsParserHook.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * A basic extension that's used by the parser tests to test whether input and
77 * arguments are passed to extensions properly.
Index: trunk/phase3/maintenance/rebuildInterwiki.inc
@@ -102,7 +102,7 @@
103103 $lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
104104
105105 if ( !$lines || count( $lines ) < 2 ) {
106 - die( "m:Interwiki_map not found" );
 106+ wfDie( "m:Interwiki_map not found" );
107107 }
108108
109109 $iwArray = array();
Index: trunk/phase3/maintenance/commandLine.inc
@@ -42,7 +42,8 @@
4343 if ( in_array( $option, $optionsWithArgs ) ) {
4444 $param = next( $argv );
4545 if ( $param === false ) {
46 - die( "$arg needs an value after it\n" );
 46+ echo "$arg needs an value after it\n";
 47+ die( -1 );
4748 }
4849 $options[$option] = $param;
4950 } else {
@@ -62,7 +63,8 @@
6364 if ( in_array( $option, $optionsWithArgs ) ) {
6465 $param = next( $argv );
6566 if ( $param === false ) {
66 - die( "$arg needs an value after it\n" );
 67+ echo "$arg needs an value after it\n";
 68+ die( -1 );
6769 }
6870 $options[$option] = $param;
6971 } else {
Index: trunk/phase3/maintenance/addwiki.php
@@ -6,7 +6,7 @@
77 require_once( "rebuildInterwiki.inc" );
88 require_once( "languages/Names.php" );
99 if ( count( $args ) != 3 ) {
10 - die( "Usage: php addwiki.php <language> <site> <dbname>\n" );
 10+ wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
1111 }
1212
1313 addWiki( $args[0], $args[1], $args[2] );
@@ -197,7 +197,7 @@
198198 $tempname = tempnam( '/tmp', 'addwiki' );
199199 $file = fopen( $tempname, 'w' );
200200 if ( !$file ) {
201 - die( "Error, unable to open temporary file $tempname\n" );
 201+ wfDie( "Error, unable to open temporary file $tempname\n" );
202202 }
203203 fwrite( $file, $sql );
204204 fclose( $file );
Index: trunk/phase3/maintenance/storage/compressOld.php
@@ -38,7 +38,7 @@
3939 if( !function_exists( "gzdeflate" ) ) {
4040 print "You must enable zlib support in PHP to compress old revisions!\n";
4141 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
42 - die();
 42+ wfDie();
4343 }
4444
4545 $defaults = array(
Index: trunk/phase3/maintenance/transstat.php
@@ -15,7 +15,7 @@
1616 require_once('commandLine.inc');
1717 require_once('languages.inc');
1818
19 -if( isset($options['help']) ) { usage(); die(); }
 19+if( isset($options['help']) ) { usage(); wfDie(); }
2020 // default output is WikiText
2121 if( !isset($options['output']) ) { $options['output']='wiki'; }
2222
@@ -121,7 +121,7 @@
122122 case 'wiki':
123123 $out = new wikiStatsOutput(); break;
124124 default:
125 - usage(); die();
 125+ usage(); wfDie();
126126 break;
127127 }
128128
Index: trunk/phase3/maintenance/benchmarkPurge.php
@@ -47,7 +47,7 @@
4848 }
4949
5050 if( !$wgUseSquid ) {
51 - die( "Squid purge benchmark doesn't do much without squid support on.\n" );
 51+ wfDie( "Squid purge benchmark doesn't do much without squid support on.\n" );
5252 } else {
5353 printf( "There are %d defined squid servers:\n", count( $wgSquidServers ) );
5454 #echo implode( "\n", $wgSquidServers ) . "\n";
Index: trunk/phase3/maintenance/parserTests.inc
@@ -121,7 +121,7 @@
122122 function runTestsFromFile( $filename ) {
123123 $infile = fopen( $filename, 'rt' );
124124 if( !$infile ) {
125 - die( "Couldn't open parserTests.txt\n" );
 125+ wfDie( "Couldn't open parserTests.txt\n" );
126126 }
127127
128128 $data = array();
@@ -135,10 +135,10 @@
136136 $section = strtolower( $matches[1] );
137137 if( $section == 'endarticle') {
138138 if( !isset( $data['text'] ) ) {
139 - die( "'endarticle' without 'text' at line $n\n" );
 139+ wfDie( "'endarticle' without 'text' at line $n\n" );
140140 }
141141 if( !isset( $data['article'] ) ) {
142 - die( "'endarticle' without 'article' at line $n\n" );
 142+ wfDie( "'endarticle' without 'article' at line $n\n" );
143143 }
144144 $this->addArticle($this->chomp($data['article']), $this->chomp($data['text']), $n);
145145 $data = array();
@@ -147,13 +147,13 @@
148148 }
149149 if( $section == 'end' ) {
150150 if( !isset( $data['test'] ) ) {
151 - die( "'end' without 'test' at line $n\n" );
 151+ wfDie( "'end' without 'test' at line $n\n" );
152152 }
153153 if( !isset( $data['input'] ) ) {
154 - die( "'end' without 'input' at line $n\n" );
 154+ wfDie( "'end' without 'input' at line $n\n" );
155155 }
156156 if( !isset( $data['result'] ) ) {
157 - die( "'end' without 'result' at line $n\n" );
 157+ wfDie( "'end' without 'result' at line $n\n" );
158158 }
159159 if( !isset( $data['options'] ) ) {
160160 $data['options'] = '';
@@ -181,7 +181,7 @@
182182 continue;
183183 }
184184 if ( isset ($data[$section] ) ) {
185 - die ( "duplicate section '$section' at line $n\n" );
 185+ wfDie( "duplicate section '$section' at line $n\n" );
186186 }
187187 $data[$section] = '';
188188 continue;
@@ -201,7 +201,7 @@
202202 print $this->termReset() . "\n";
203203 return ($success == $total);
204204 } else {
205 - die( "No tests found.\n" );
 205+ wfDie( "No tests found.\n" );
206206 }
207207 }
208208
@@ -386,7 +386,7 @@
387387 . $wgDBprefix . $tbl .'`', $create);
388388 if ($create === $create_tmp) {
389389 # Couldn't do replacement
390 - die("could not create temporary table $tbl");
 390+ wfDie("could not create temporary table $tbl");
391391 }
392392 $db->query($create_tmp);
393393 }
@@ -638,12 +638,12 @@
639639 $this->setupGlobals();
640640 $title = Title::newFromText( $name );
641641 if ( is_null($title) ) {
642 - die( "invalid title at line $line\n" );
 642+ wfDie( "invalid title at line $line\n" );
643643 }
644644
645645 $aid = $title->getArticleID( GAID_FOR_UPDATE );
646646 if ($aid != 0) {
647 - die( "duplicate article at line $line\n" );
 647+ wfDie( "duplicate article at line $line\n" );
648648 }
649649
650650 $art = new Article($title);
Index: trunk/phase3/maintenance/lang2po.php
@@ -22,7 +22,7 @@
2323 define('LOCALE_OUTPUT_DIR', $IP.'/locale');
2424
2525
26 -if( isset($options['help']) ) { usage(); die(); }
 26+if( isset($options['help']) ) { usage(); wfDie(); }
2727 // default output is WikiText
2828 if( !isset($options['lang']) ) { $options['lang'] = ALL_LANGUAGES; }
2929
Index: trunk/phase3/maintenance/mwdocgen.php
@@ -23,7 +23,8 @@
2424 #
2525
2626 if( php_sapi_name() != 'cli' ) {
27 - die( "Run me from the command line." );
 27+ echo "Run me from the command line.";
 28+ die( -1 );
2829 }
2930
3031 /** Phpdoc script with full path */
Index: trunk/phase3/maintenance/langmemusage.php
@@ -11,7 +11,7 @@
1212 $langtool = new languages();
1313
1414 if ( ! function_exists( 'memory_get_usage' ) )
15 - die( "You must compile PHP with --enable-memory-limit\n" );
 15+ wfDie( "You must compile PHP with --enable-memory-limit\n" );
1616
1717 $memlast = $memstart = memory_get_usage();
1818
Index: trunk/phase3/maintenance/parserTestsParserTime.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * A basic extension that's used by the parser tests to test date magic words
77 *
Index: trunk/phase3/maintenance/generateSitemap.php
@@ -441,7 +441,7 @@
442442 }
443443
444444 if ( in_array( '--help', $argv ) )
445 - die(
 445+ wfDie(
446446 "Usage: php generateSitemap.php [host] [options]\n" .
447447 "\thost = hostname\n" .
448448 "\toptions:\n" .
Index: trunk/phase3/img_auth.php
@@ -11,7 +11,8 @@
1212 define( 'MEDIAWIKI', true );
1313
1414 if ( isset( $_REQUEST['GLOBALS'] ) ) {
15 - die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
 15+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
 16+ die( -1 );
1617 }
1718
1819 require_once( 'includes/Defines.php' );
Index: trunk/phase3/redirect.php
@@ -4,7 +4,8 @@
55 $wgCommandLineMode = false;
66 define( 'MEDIAWIKI', true );
77 if ( isset( $_REQUEST['GLOBALS'] ) ) {
8 - die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
 8+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
 9+ die( -1 );
910 }
1011
1112 require_once( './includes/Defines.php' );
Index: trunk/phase3/skins/MySkin.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /** */
1515 require_once('MonoBook.php');
Index: trunk/phase3/skins/Chick.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /** */
1515 require_once('MonoBook.php');
Index: trunk/phase3/skins/Nostalgia.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /**
1515 * @todo document
Index: trunk/phase3/skins/disabled/HTMLDump.php
@@ -5,7 +5,7 @@
66 */
77
88 if( !defined( 'MEDIAWIKI' ) )
9 - die();
 9+ die( -1 );
1010
1111 /** */
1212 require_once( 'includes/SkinTemplate.php' );
Index: trunk/phase3/skins/disabled/Amethyst.php
@@ -10,7 +10,7 @@
1111 */
1212
1313 if( !defined( 'MEDIAWIKI' ) )
14 - die();
 14+ die( -1 );
1515
1616 /** Skin reuse monobook template */
1717 require_once('MonoBook.php');
Index: trunk/phase3/skins/disabled/Chick.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /** */
1515 require_once('includes/SkinPHPTal.php');
Index: trunk/phase3/skins/disabled/MonoBookTal.php
@@ -15,7 +15,7 @@
1616 */
1717
1818 if( !defined( 'MEDIAWIKI' ) )
19 - die();
 19+ die( -1 );
2020
2121 /** */
2222 require_once('includes/SkinPHPTal.php');
Index: trunk/phase3/skins/disabled/WikimediaWiki.php
@@ -7,7 +7,7 @@
88 */
99
1010 if( !defined( 'MEDIAWIKI' ) )
11 - die();
 11+ die( -1 );
1212
1313 /** */
1414
Index: trunk/phase3/skins/MonoBook.php
@@ -11,7 +11,7 @@
1212 */
1313
1414 if( !defined( 'MEDIAWIKI' ) )
15 - die();
 15+ die( -1 );
1616
1717 /** */
1818 require_once('includes/SkinTemplate.php');
Index: trunk/phase3/skins/Simple.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /** */
1515 require_once('MonoBook.php');
Index: trunk/phase3/skins/CologneBlue.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /**
1515 * @todo document
Index: trunk/phase3/skins/Standard.php
@@ -8,7 +8,7 @@
99 */
1010
1111 if( !defined( 'MEDIAWIKI' ) )
12 - die();
 12+ die( -1 );
1313
1414 /**
1515 * @todo document
Index: trunk/phase3/profileinfo.php
@@ -49,19 +49,21 @@
5050 define("MEDIAWIKI", 1);
5151 if ( isset( $_REQUEST['GLOBALS'] ) ) {
5252 print $GLOBALS;
53 - die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
 53+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
 54+ die( -1 );
5455 }
5556
5657 require_once("./includes/Defines.php");
5758 require_once("./LocalSettings.php");
5859 require_once("./AdminSettings.php");
5960
60 -if (!$wgEnableProfileInfo)
61 - die("disabled");
 61+if (!$wgEnableProfileInfo) {
 62+ wfDie("disabled");
 63+}
6264
6365 foreach (array("wgDBadminuser", "wgDBadminpassword", "wgDBserver", "wgDBname") as $var)
6466 if ($$var === false)
65 - die("AdminSettings.php not correct");
 67+ wfDie("AdminSettings.php not correct");
6668
6769 $expand = array();
6870 if (isset($_REQUEST['expand']))
@@ -155,13 +157,13 @@
156158 $sort = $_REQUEST['sort'];
157159
158160 $dbh = mysql_connect($wgDBserver, $wgDBadminuser, $wgDBadminpassword)
159 - or die("mysql server failed: " . mysql_error());
160 -mysql_select_db($wgDBname, $dbh) or die(mysql_error($dbh));
 161+ or wfDie("mysql server failed: " . mysql_error());
 162+mysql_select_db($wgDBname, $dbh) or wfDie(mysql_error($dbh));
161163 $res = mysql_query("
162164 SELECT pf_count, pf_time, pf_name
163165 FROM profiling
164166 ORDER BY pf_name ASC
165 -", $dbh) or die("query failed: " . mysql_error());
 167+", $dbh) or wfDie("query failed: " . mysql_error());
166168
167169 if (isset($_REQUEST['filter']))
168170 $filter = $_REQUEST['filter'];
Index: trunk/phase3/tests/RunTests.php
@@ -1,7 +1,8 @@
22 <?php
33
44 if( php_sapi_name() != 'cli' ) {
5 - die( 'Must be run from the command line.' );
 5+ echo 'Must be run from the command line.';
 6+ die( -1 );
67 }
78
89 error_reporting( E_ALL );
@@ -74,7 +75,7 @@
7576 . $wgDBprefix . '\\1`', $create);
7677 if ($create === $create_tmp) {
7778 # Couldn't do replacement
78 - die("could not create temporary table $tbl");
 79+ wfDie( "could not create temporary table $tbl" );
7980 }
8081 $db->query($create_tmp);
8182 }
Index: trunk/phase3/thumb.php
@@ -8,7 +8,8 @@
99 define( 'MEDIAWIKI', true );
1010 unset( $IP );
1111 if ( isset( $_REQUEST['GLOBALS'] ) ) {
12 - die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
 12+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
 13+ die( -1 );
1314 }
1415
1516 $wgNoOutputBuffer = true;
Index: trunk/phase3/languages/LanguageConverter.php
@@ -434,7 +434,7 @@
435435 */
436436 function loadDefaultTables() {
437437 $name = get_class($this);
438 - die("Must implement loadDefaultTables() method in class $name");
 438+ wfDie("Must implement loadDefaultTables() method in class $name");
439439 }
440440
441441 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -484,6 +484,8 @@
485485 * Add wfClone() wrapper since we're still using PHP 4 on some servers.
486486 * Fixed installer bugs 921 and 3914 (issues with using root and so forth)
487487 * Remove obsolete killthread.php
 488+* Added wfDie() wrapper, and some manual die(-1), to force the return code
 489+ to the shell to return nonzero when we crap out with an error.
488490
489491
490492 === Caveats ===
Index: trunk/phase3/includes/Database.php
@@ -255,7 +255,7 @@
256256
257257 # Otherwise we get a suppressed fatal error, which is very hard to track down
258258 if ( !function_exists( 'mysql_connect' ) ) {
259 - die( "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
 259+ wfDie( "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
260260 }
261261
262262 $this->close();
Index: trunk/phase3/includes/SkinPHPTal.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 # This program is free software; you can redistribute it and/or modify
66 # it under the terms of the GNU General Public License as published by
77 # the Free Software Foundation; either version 2 of the License, or
Index: trunk/phase3/includes/Namespace.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * Provide things related to namespaces
77 * @package MediaWiki
Index: trunk/phase3/includes/HistoryBlob.php
@@ -59,7 +59,7 @@
6060
6161 function ConcatenatedGzipHistoryBlob() {
6262 if ( !function_exists( 'gzdeflate' ) ) {
63 - die( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
 63+ wfDie( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
6464 }
6565 }
6666
Index: trunk/phase3/includes/OutputPage.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * @package MediaWiki
77 */
Index: trunk/phase3/includes/Setup.php
@@ -18,7 +18,8 @@
1919
2020 // Check to see if we are at the file scope
2121 if ( !isset( $wgVersion ) ) {
22 - die( "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n" );
 22+ echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
 23+ die( -1 );
2324 }
2425
2526 if( !isset( $wgProfiling ) )
Index: trunk/phase3/includes/SkinTemplate.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55
66 # This program is free software; you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
Index: trunk/phase3/includes/ObjectCache.php
@@ -5,7 +5,10 @@
66 */
77
88 /** */
9 -if (!defined('MEDIAWIKI')) die( "Not a valid entry point\n");
 9+if (!defined('MEDIAWIKI')) {
 10+ echo "Not a valid entry point\n";
 11+ die( -1 );
 12+}
1013
1114
1215 /**
Index: trunk/phase3/includes/DatabaseOracle.php
@@ -52,7 +52,7 @@
5353 */
5454 function open( $server, $user, $password, $dbName ) {
5555 if ( !function_exists( 'oci_connect' ) ) {
56 - die( "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n" );
 56+ wfDie( "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n" );
5757 }
5858 $this->close();
5959 $this->mServer = $server;
Index: trunk/phase3/includes/Skin.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55
66 /**
77 *
Index: trunk/phase3/includes/DefaultSettings.php
@@ -20,7 +20,8 @@
2121
2222 # This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
2323 if( !defined( 'MEDIAWIKI' ) ) {
24 - die( "This file is part of MediaWiki and is not a valid entry point\n" );
 24+ echo "This file is part of MediaWiki and is not a valid entry point\n";
 25+ die( -1 );
2526 }
2627
2728 /**
Index: trunk/phase3/includes/Categoryfinder.php
@@ -21,7 +21,7 @@
2222 */
2323
2424
25 -if( !defined( 'MEDIAWIKI' ) ) die();
 25+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
2626
2727 class Categoryfinder {
2828
Index: trunk/phase3/includes/Hooks.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * Hooks.php -- a tool for running hook functions
77 * Copyright 2004, 2005 Evan Prodromou <evan@wikitravel.org>.
Index: trunk/phase3/includes/PersistentObject.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * Sometimes one wants to make an extension that defines a class that one wants
77 * to backreference somewhere else in the code, doing something like:
Index: trunk/phase3/includes/ImageGallery.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55
66 /**
77 * @package MediaWiki
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -6,7 +6,7 @@
77 */
88
99 if( !defined( 'MEDIAWIKI' ) )
10 - die();
 10+ die( -1 );
1111
1212 /**
1313 * Entry point that create the "Preferences" object
Index: trunk/phase3/includes/compatability/ctype.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * PHP <4.2.0 doesn't build ctype_ functions by default and Gentoo doesn't
77 * build it by default, and that probably applies for some other distributions
Index: trunk/phase3/includes/proxy_check.php
@@ -5,7 +5,7 @@
66 */
77
88 if( php_sapi_name() != 'cli' ) {
9 - die('');
 9+ die( -1 );
1010 }
1111
1212 /**
Index: trunk/phase3/includes/BagOStuff.php
@@ -293,14 +293,14 @@
294294 return $str;
295295 }
296296 function _doinsert($table, $vals) {
297 - die( 'abstract function SqlBagOStuff::_doinsert() must be defined' );
 297+ wfDie( 'abstract function SqlBagOStuff::_doinsert() must be defined' );
298298 }
299299 function _doquery($sql) {
300 - die( 'abstract function SqlBagOStuff::_doquery() must be defined' );
 300+ wfDie( 'abstract function SqlBagOStuff::_doquery() must be defined' );
301301 }
302302
303303 function _fetchrow($res) {
304 - die( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
 304+ wfDie( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
305305 }
306306
307307 function _freeresult($result) {
@@ -314,11 +314,11 @@
315315 }
316316
317317 function _maxdatetime() {
318 - die( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
 318+ wfDie( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
319319 }
320320
321321 function _fromunixtime() {
322 - die( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
 322+ wfDie( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
323323 }
324324
325325 function garbageCollect() {
@@ -427,7 +427,7 @@
428428 /* This is actually a hack, we should be able
429429 to use Language classes here... or not */
430430 if (!$dbw)
431 - die("Could not connect to database");
 431+ wfDie("Could not connect to database");
432432 $this->table = $dbw->tableName( $this->table );
433433 $this->tableInitialised = true;
434434 }
Index: trunk/phase3/includes/DatabasePostgreSQL.php
@@ -45,7 +45,7 @@
4646 function open( $server, $user, $password, $dbName ) {
4747 # Test for PostgreSQL support, to avoid suppressed fatal error
4848 if ( !function_exists( 'pg_connect' ) ) {
49 - die( "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" );
 49+ wfDie( "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" );
5050 }
5151
5252 global $wgDBschema;
Index: trunk/phase3/includes/CategoryPage.php
@@ -7,7 +7,7 @@
88 */
99
1010 if( !defined( 'MEDIAWIKI' ) )
11 - die();
 11+ die( -1 );
1212
1313 global $wgCategoryMagicGallery;
1414 if( $wgCategoryMagicGallery )
Index: trunk/phase3/includes/ImagePage.php
@@ -7,7 +7,7 @@
88 *
99 */
1010 if( !defined( 'MEDIAWIKI' ) )
11 - die();
 11+ die( -1 );
1212
1313 require_once( 'Image.php' );
1414
Index: trunk/phase3/includes/Export.php
@@ -588,7 +588,7 @@
589589 $ns = intval( $key );
590590 $this->namespaces[$ns] = true;
591591 } else {
592 - die( "Unrecognized namespace key '$key'\n" );
 592+ wfDie( "Unrecognized namespace key '$key'\n" );
593593 }
594594 }
595595 }
Index: trunk/phase3/includes/normal/UtfNormalUtil.php
@@ -47,7 +47,8 @@
4848 chr($codepoint >> 6 & 0x3f | 0x80) .
4949 chr($codepoint & 0x3f | 0x80);
5050
51 - die("Asked for code outside of range ($codepoint)\n");
 51+ echo "Asked for code outside of range ($codepoint)\n";
 52+ die( -1 );
5253 }
5354
5455 /**
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -582,6 +582,16 @@
583583 }
584584
585585 /**
 586+ * Print a simple message and die, returning nonzero to the shell if any.
 587+ * Plain die() fails to return nonzero to the shell if you pass a string.
 588+ * @param string $msg
 589+ */
 590+function wfDie( $msg='' ) {
 591+ echo $msg;
 592+ die( -1 );
 593+}
 594+
 595+/**
586596 * Die with a backtrace
587597 * This is meant as a debugging aid to track down where bad data comes from.
588598 * Shouldn't be used in production code except maybe in "shouldn't happen" areas.
@@ -1763,4 +1773,5 @@
17641774 return $string;
17651775 }
17661776
 1777+
17671778 ?>
Index: trunk/phase3/includes/Exif.php
@@ -1,5 +1,5 @@
22 <?php
3 -if ( !defined( 'MEDIAWIKI' ) ) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die( -1 );
44 /**
55 * @package MediaWiki
66 * @subpackage Metadata
Index: trunk/phase3/includes/ProxyTools.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die( -1 );
55 /**
66 * Functions for dealing with proxies
77 * @package MediaWiki
Index: trunk/phase3/includes/templates/Confirmemail.php
@@ -3,7 +3,7 @@
44 * @package MediaWiki
55 * @subpackage Templates
66 */
7 -if( !defined( 'MEDIAWIKI' ) ) die();
 7+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
88
99 /** */
1010 require_once( 'includes/SkinTemplate.php' );
Index: trunk/phase3/includes/templates/Userlogin.php
@@ -3,7 +3,7 @@
44 * @package MediaWiki
55 * @subpackage Templates
66 */
7 -if( !defined( 'MEDIAWIKI' ) ) die();
 7+if( !defined( 'MEDIAWIKI' ) ) die( -1 );
88
99 /** */
1010 require_once( 'includes/SkinTemplate.php' );
Index: trunk/phase3/trackback.php
@@ -8,7 +8,8 @@
99 unset($IP);
1010 define('MEDIAWIKI', true);
1111 if ( isset( $_REQUEST['GLOBALS'] ) ) {
12 - die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
 12+ echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
 13+ die( -1 );
1314 }
1415
1516 require_once('./includes/Defines.php');

Status & tagging log