Removed most exit() calls from the MediaWiki core, by replacing them with either...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 7 Jun 2006 06:40:24 +0000 (06:40 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 7 Jun 2006 06:40:24 +0000 (06:40 +0000)
40 files changed:
includes/Article.php
includes/BagOStuff.php
includes/DatabaseFunctions.php
includes/Exception.php
includes/Export.php
includes/FakeTitle.php
includes/GlobalFunctions.php
includes/Group.php
includes/HistoryBlob.php
includes/Hooks.php
includes/Image.php
includes/ImageGallery.php
includes/ImagePage.php
includes/Linker.php
includes/LinksUpdate.php
includes/MagicWord.php
includes/MessageCache.php
includes/OutputPage.php
includes/Parser.php
includes/ProtectionForm.php
includes/Revision.php
includes/Sanitizer.php
includes/Setup.php
includes/Skin.php
includes/SpecialContributions.php
includes/SpecialEmailuser.php
includes/SpecialLockdb.php
includes/SpecialMovepage.php
includes/SpecialPage.php
includes/SpecialPreferences.php
includes/SpecialRevisiondelete.php
includes/SpecialUndelete.php
includes/SpecialUnlockdb.php
includes/SpecialUpload.php
includes/SpecialUploadMogile.php
includes/SpecialWhatlinkshere.php
includes/Title.php
includes/User.php
includes/WebRequest.php
includes/Wiki.php

index 1162a9c..ecd5410 100644 (file)
@@ -1464,7 +1464,7 @@ class Article {
                        $wgOut->returnToMain( false, $rcTitle->getPrefixedText() );
                }
                else {
-                       $wgOut->errorpage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
+                       $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
                }
        }
 
@@ -1477,7 +1477,7 @@ class Article {
                global $wgUser, $wgOut;
 
                if ( $wgUser->isAnon() ) {
-                       $wgOut->errorpage( 'watchnologin', 'watchnologintext' );
+                       $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
                        return;
                }
                if ( wfReadOnly() ) {
@@ -1525,7 +1525,7 @@ class Article {
                global $wgUser, $wgOut;
 
                if ( $wgUser->isAnon() ) {
-                       $wgOut->errorpage( 'watchnologin', 'watchnologintext' );
+                       $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
                        return;
                }
                if ( wfReadOnly() ) {
@@ -1658,7 +1658,7 @@ class Article {
         */
        function flattenRestrictions( $limit ) {
                if( !is_array( $limit ) ) {
-                       wfDebugDieBacktrace( 'Article::flattenRestrictions given non-array restriction set' );
+                       throw new MWException( 'Article::flattenRestrictions given non-array restriction set' );
                }
                $bits = array();
                ksort( $limit );
@@ -1705,7 +1705,7 @@ class Article {
                $conds = $this->mTitle->pageCond();
                $latest = $dbw->selectField( 'page', 'page_latest', $conds, $fname );
                if ( $latest === false ) {
-                       $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
+                       $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
                        return;
                }
 
@@ -1899,7 +1899,7 @@ class Article {
                                $wgOut->returnToMain( false );
                                wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason));
                        } else {
-                               $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
+                               $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
                        }
                }
        }
@@ -2522,7 +2522,7 @@ class Article {
                $fname = 'Article::info';
 
                if ( !$wgAllowPageInfo ) {
-                       $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
+                       $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
                        return;
                }
 
index ae5e6fd..c48aef9 100644 (file)
@@ -35,7 +35,7 @@
  * @package MediaWiki
  * @abstract
  */
-class BagOStuff {
+abstract class BagOStuff {
        var $debugmode;
 
        function BagOStuff() {
@@ -212,7 +212,7 @@ CREATE TABLE objectcache (
  * @abstract
  * @package MediaWiki
  */
-class SqlBagOStuff extends BagOStuff {
+abstract class SqlBagOStuff extends BagOStuff {
        var $table;
        var $lastexpireall = 0;
 
@@ -292,16 +292,9 @@ class SqlBagOStuff extends BagOStuff {
        function _blobencode($str) {
                return $str;
        }
-       function _doinsert($table, $vals) {
-               wfDie( 'abstract function SqlBagOStuff::_doinsert() must be defined' );
-       }
-       function _doquery($sql) {
-               wfDie( 'abstract function SqlBagOStuff::_doquery() must be defined' );
-       }
 
-       function _fetchrow($res) {
-               wfDie( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
-       }
+       abstract function _doinsert($table, $vals);
+       abstract function _doquery($sql);
 
        function _freeresult($result) {
                /* stub */
@@ -313,13 +306,8 @@ class SqlBagOStuff extends BagOStuff {
                return 'unknown error';
        }
 
-       function _maxdatetime() {
-               wfDie( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
-       }
-
-       function _fromunixtime() {
-               wfDie( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
-       }
+       abstract function _maxdatetime();
+       abstract function _fromunixtime($ts);
 
        function garbageCollect() {
                /* Ignore 99% of requests */
@@ -427,7 +415,7 @@ class MediaWikiBagOStuff extends SqlBagOStuff {
                        /* This is actually a hack, we should be able
                           to use Language classes here... or not */
                        if (!$dbw)
-                               wfDie("Could not connect to database");
+                               throw new MWException("Could not connect to database");
                        $this->table = $dbw->tableName( $this->table );
                        $this->tableInitialised = true;
                }
index 61ba5ba..74b35a3 100644 (file)
@@ -18,7 +18,7 @@ function wfQuery( $sql, $db, $fname = '' ) {
        global $wgOut;
        if ( !is_numeric( $db ) ) {
                # Someone has tried to call this the old way
-               $wgOut->fatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) );
+               throw new FatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) );
        }
        $c =& wfGetDB( $db );
        if ( $c !== false ) {
index 11bb597..1e24515 100644 (file)
-<?php\r
-\r
-class MWException extends Exception\r
-{\r
-       function useOutputPage() {\r
-               return !empty( $GLOBALS['wgFullyInitialised'] );\r
-       }\r
-\r
-       function useMessageCache() {\r
-               global $wgLang;\r
-               return is_object( $wgLang );\r
-       }\r
-\r
-       function msg( $key, $fallback /*[, params...] */ ) {\r
-               $args = array_slice( func_get_args(), 2 );\r
-               if ( $this->useMessageCache() ) {\r
-                       return wfMsgReal( $key, $args );\r
-               } else {\r
-                       return wfMsgReplaceArgs( $fallback, $args );\r
-               }\r
-       }\r
-                       \r
-       function getHTML() {\r
-               return '<p>' . htmlspecialchars( $this->getMessage() ) . \r
-                       '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .\r
-                       "</p>\n";\r
-       }\r
-\r
-       function getText() {\r
-               return $this->getMessage() .  \r
-                       "\nBacktrace:\n" . $this->getTraceAsString() . "\n";\r
-       }\r
-       \r
-       function getPageTitle() {\r
-               if ( $this->useMessageCache() ) {\r
-                       return wfMsg( 'internalerror' );\r
-               } else {\r
-                       global $wgSitename;\r
-                       return "$wgSitename error";\r
-               }\r
-       }\r
-       \r
-       function reportHTML() {\r
-               global $wgOut;\r
-               if ( $this->useOutputPage() ) {\r
-                       $wgOut->setPageTitle( $this->getPageTitle() );\r
-                       $wgOut->setRobotpolicy( "noindex,nofollow" );\r
-                       $wgOut->setArticleRelated( false );\r
-                       $wgOut->enableClientCache( false );\r
-                       $wgOut->redirect( '' );\r
-                       $wgOut->clearHTML();\r
-                       $wgOut->addHTML( $this->getHTML() );\r
-                       $wgOut->output();\r
-               } else {\r
-                       echo $this->htmlHeader();\r
-                       echo $this->getHTML();\r
-                       echo $this->htmlFooter();\r
-               }\r
-       }\r
-       \r
-       function reportText() {\r
-               echo $this->getText();\r
-       }\r
-\r
-       function report() {\r
-               global $wgCommandLineMode;\r
-               if ( $wgCommandLineMode ) {\r
-                       $this->reportText();\r
-               } else {\r
-                       $this->reportHTML();\r
-               }\r
-       }\r
-\r
-       function htmlHeader() {\r
-               global $wgLogo, $wgSitename, $wgOutputEncoding;\r
-\r
-               if ( !headers_sent() ) {\r
-                       header( 'HTTP/1.0 500 Internal Server Error' );\r
-                       header( 'Content-type: text/html; charset='.$wgOutputEncoding );\r
-                       /* Don't cache error pages!  They cause no end of trouble... */\r
-                       header( 'Cache-control: none' );\r
-                       header( 'Pragma: nocache' );\r
-               }\r
-               $title = $this->getPageTitle();\r
-               echo "<html>\r
-               <head>\r
-               <title>$title</title>\r
-               </head>\r
-               <body>\r
-               <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''>$title</h1>\r
-               ";\r
-       }\r
-\r
-       function htmlFooter() {\r
-               echo "</body></html>";\r
-       }               \r
-}\r
-\r
-/**\r
- * Exception class which takes an HTML error message, and does not \r
- * produce a backtrace. Replacement for OutputPage::fatalError().\r
- */\r
-class FatalError extends MWException {\r
-       function getHTML() {\r
-               return $this->getMessage();\r
-       }\r
-\r
-       function getText() {\r
-               return $this->getMessage();\r
-       }\r
-}\r
-\r
-/**\r
- * Install an exception handler for MediaWiki exception types.\r
- */\r
-function wfInstallExceptionHandler() {\r
-       set_exception_handler( 'wfExceptionHandler' );\r
-}\r
-\r
-/**\r
- * Report an exception to the user\r
- */\r
-function wfReportException( Exception $e ) {\r
-        if ( is_a( $e, 'MWException' ) ) {\r
-                try {\r
-                        $e->report();\r
-                } catch ( Exception $e2 ) {\r
-                        // Exception occurred from within exception handler\r
-                        // Show a simpler error message for the original exception, \r
-                        // don't try to invoke report()\r
-                        $message = "MediaWiki internal error.\n\n" .\r
-                        "Original exception: " . $e->__toString() . \r
-                        "\n\nException caught inside exception handler: " . \r
-                        $e2->__toString() . "\n";\r
-\r
-                        if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) {\r
-                                echo $message;\r
-                        } else {\r
-                                echo nl2br( htmlspecialchars( $message ) ). "\n";\r
-                        }\r
-                }\r
-        } else {\r
-                echo $e->__toString();\r
-        }\r
-}\r
-\r
-/**\r
- * Exception handler which simulates the appropriate catch() handling:\r
- * \r
- *   try {\r
- *       ...\r
- *   } catch ( MWException $e ) {\r
- * \r
- *       $e->report();\r
- *   } catch ( Exception $e ) {\r
- *       echo $e->__toString();\r
- *   }\r
- */\r
-function wfExceptionHandler( $e ) {\r
-       wfReportException( $e );\r
-       \r
-       // Final cleanup, similar to wfErrorExit()\r
-       try {\r
-               wfProfileClose();\r
-               logProfilingData();\r
-       } catch ( Exception $e ) {}\r
-\r
-       // Exit value should be nonzero for the benefit of shell jobs\r
-       exit( 1 );\r
-}\r
-\r
-?>\r
+<?php
+
+class MWException extends Exception
+{
+       function useOutputPage() {
+               return !empty( $GLOBALS['wgFullyInitialised'] );
+       }
+
+       function useMessageCache() {
+               global $wgLang;
+               return is_object( $wgLang );
+       }
+
+       function msg( $key, $fallback /*[, params...] */ ) {
+               $args = array_slice( func_get_args(), 2 );
+               if ( $this->useMessageCache() ) {
+                       return wfMsgReal( $key, $args );
+               } else {
+                       return wfMsgReplaceArgs( $fallback, $args );
+               }
+       }
+                       
+       function getHTML() {
+               return '<p>' . htmlspecialchars( $this->getMessage() ) . 
+                       '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
+                       "</p>\n";
+       }
+
+       function getText() {
+               return $this->getMessage() .  
+                       "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
+       }
+       
+       function getPageTitle() {
+               if ( $this->useMessageCache() ) {
+                       return wfMsg( 'internalerror' );
+               } else {
+                       global $wgSitename;
+                       return "$wgSitename error";
+               }
+       }
+       
+       function reportHTML() {
+               global $wgOut;
+               if ( $this->useOutputPage() ) {
+                       $wgOut->setPageTitle( $this->getPageTitle() );
+                       $wgOut->setRobotpolicy( "noindex,nofollow" );
+                       $wgOut->setArticleRelated( false );
+                       $wgOut->enableClientCache( false );
+                       $wgOut->redirect( '' );
+                       $wgOut->clearHTML();
+                       $wgOut->addHTML( $this->getHTML() );
+                       $wgOut->output();
+               } else {
+                       echo $this->htmlHeader();
+                       echo $this->getHTML();
+                       echo $this->htmlFooter();
+               }
+       }
+       
+       function reportText() {
+               echo $this->getText();
+       }
+
+       function report() {
+               global $wgCommandLineMode;
+               if ( $wgCommandLineMode ) {
+                       $this->reportText();
+               } else {
+                       $this->reportHTML();
+               }
+       }
+
+       function htmlHeader() {
+               global $wgLogo, $wgSitename, $wgOutputEncoding;
+
+               if ( !headers_sent() ) {
+                       header( 'HTTP/1.0 500 Internal Server Error' );
+                       header( 'Content-type: text/html; charset='.$wgOutputEncoding );
+                       /* Don't cache error pages!  They cause no end of trouble... */
+                       header( 'Cache-control: none' );
+                       header( 'Pragma: nocache' );
+               }
+               $title = $this->getPageTitle();
+               echo "<html>
+               <head>
+               <title>$title</title>
+               </head>
+               <body>
+               <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''>$title</h1>
+               ";
+       }
+
+       function htmlFooter() {
+               echo "</body></html>";
+       }               
+}
+
+/**
+ * Exception class which takes an HTML error message, and does not 
+ * produce a backtrace. Replacement for OutputPage::fatalError().
+ */
+class FatalError extends MWException {
+       function getHTML() {
+               return $this->getMessage();
+       }
+
+       function getText() {
+               return $this->getMessage();
+       }
+}
+
+class ErrorPageError extends MWException {
+       public $title, $msg;
+       
+       /**
+        * Note: these arguments are keys into wfMsg(), not text!
+        */
+       function __construct( $title, $msg ) {
+               $this->title = $title;
+               $this->msg = $msg;
+               parent::__construct( wfMsg( $msg ) );
+       }
+
+       function report() {
+               global $wgOut;
+               $wgOut->showErrorPage( $this->title, $this->msg );
+               $wgOut->output();
+       }
+}
+
+/**
+ * Install an exception handler for MediaWiki exception types.
+ */
+function wfInstallExceptionHandler() {
+       set_exception_handler( 'wfExceptionHandler' );
+}
+
+/**
+ * Report an exception to the user
+ */
+function wfReportException( Exception $e ) {
+        if ( is_a( $e, 'MWException' ) ) {
+                try {
+                        $e->report();
+                } catch ( Exception $e2 ) {
+                        // Exception occurred from within exception handler
+                        // Show a simpler error message for the original exception, 
+                        // don't try to invoke report()
+                        $message = "MediaWiki internal error.\n\n" .
+                        "Original exception: " . $e->__toString() . 
+                        "\n\nException caught inside exception handler: " . 
+                        $e2->__toString() . "\n";
+
+                        if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) {
+                                echo $message;
+                        } else {
+                                echo nl2br( htmlspecialchars( $message ) ). "\n";
+                        }
+                }
+        } else {
+                echo $e->__toString();
+        }
+}
+
+/**
+ * Exception handler which simulates the appropriate catch() handling:
+ * 
+ *   try {
+ *       ...
+ *   } catch ( MWException $e ) {
+ *       $e->report();
+ *   } catch ( Exception $e ) {
+ *       echo $e->__toString();
+ *   }
+ */
+function wfExceptionHandler( $e ) {
+       global $wgFullyInitialised;
+       wfReportException( $e );
+       
+       // Final cleanup, similar to wfErrorExit()
+       if ( $wgFullyInitialised ) {
+               try {
+                       wfProfileClose();
+                       logProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition
+               } catch ( Exception $e ) {}
+       }
+
+       // Exit value should be nonzero for the benefit of shell jobs
+       exit( 1 );
+}
+
+?>
index 91eecfa..88a83d9 100644 (file)
@@ -634,7 +634,7 @@ class DumpNamespaceFilter extends DumpFilter {
                                $ns = intval( $key );
                                $this->namespaces[$ns] = true;
                        } else {
-                               wfDie( "Unrecognized namespace key '$key'\n" );
+                               throw new MWException( "Unrecognized namespace key '$key'\n" );
                        }
                }
        }
index a6fd840..ae05385 100644 (file)
@@ -4,7 +4,7 @@
  * Fake title class that triggers an error if any members are called
  */
 class FakeTitle {
-       function error() { wfDebugDieBacktrace( "Attempt to call member function of FakeTitle\n" ); }
+       function error() { throw new MWException( "Attempt to call member function of FakeTitle\n" ); }
 
        // PHP 5.1 method overload
        function __call( $name, $args ) { $this->error(); }
index a94ed8a..ed41259 100644 (file)
@@ -642,7 +642,7 @@ function wfErrorExit() {
  */
 function wfDie( $msg='' ) {
        echo $msg;
-       die( -1 );
+       die( 1 );
 }
 
 /**
@@ -665,7 +665,7 @@ function wfDebugDieBacktrace( $msg = '' ) {
        }
        echo $msg;
        echo wfReportTime()."\n";
-       die( -1 );
+       die( 1 );
 }
 
 /**
@@ -1364,7 +1364,7 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
                case TS_ORACLE:
                        return gmdate( 'd-M-y h.i.s A', $uts) . ' +00:00';
                default:
-                       wfDebugDieBacktrace( 'wfTimestamp() called with illegal output type.');
+                       throw new MWException( 'wfTimestamp() called with illegal output type.');
        }
 }
 
@@ -1605,7 +1605,7 @@ function wfEncryptPassword( $userid, $password ) {
  */
 function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
        if ( is_null( $changed ) ) {
-               wfDebugDieBacktrace('GlobalFunctions::wfAppendToArrayIfNotDefault got null');
+               throw new MWException('GlobalFunctions::wfAppendToArrayIfNotDefault got null');
        }
        if ( $default[$key] !== $value ) {
                $changed[$key] = $value;
@@ -1726,7 +1726,7 @@ function wfUsePHP( $req_ver ) {
        $php_ver = PHP_VERSION;
 
        if ( version_compare( $php_ver, (string)$req_ver, '<' ) )
-                wfDebugDieBacktrace( "PHP $req_ver required--this is only $php_ver" );
+                throw new MWException( "PHP $req_ver required--this is only $php_ver" );
 }
 
 /**
@@ -1746,7 +1746,7 @@ function wfUseMW( $req_ver ) {
        global $wgVersion;
 
        if ( version_compare( $wgVersion, (string)$req_ver, '<' ) )
-               wfDebugDieBacktrace( "MediaWiki $req_ver required--this is only $wgVersion" );
+               throw new MWException( "MediaWiki $req_ver required--this is only $wgVersion" );
 }
 
 /**
index f50f190..cc94a69 100644 (file)
@@ -90,7 +90,7 @@ class Group {
        /** Initialise a new row in the database */
        function addToDatabase() {
                if ( Group::getStaticGroups() ) {
-                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+                       throw new MWException( "Can't modify groups in static mode" );
                }
 
                $fname = 'Group::addToDatabase';
@@ -110,7 +110,7 @@ class Group {
                global $wgMemc;
 
                if ( Group::getStaticGroups() ) {
-                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+                       throw new MWException( "Can't modify groups in static mode" );
                }
                if($this->id == 0) { return; }
 
@@ -136,7 +136,7 @@ class Group {
                global $wgMemc;
 
                if ( Group::getStaticGroups() ) {
-                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+                       throw new MWException( "Can't modify groups in static mode" );
                }
                if($this->id == 0) { return; }
 
index 4dee4da..8f5d362 100644 (file)
@@ -59,7 +59,7 @@ class ConcatenatedGzipHistoryBlob extends HistoryBlob
 
        function ConcatenatedGzipHistoryBlob() {
                if ( !function_exists( 'gzdeflate' ) ) {
-                       wfDie( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
+                       throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
                }
        }
 
index fc408e8..4daffaf 100644 (file)
@@ -34,7 +34,7 @@ function wfRunHooks($event, $args = null) {
        $fname = 'wfRunHooks';
 
        if (!is_array($wgHooks)) {
-               wfDebugDieBacktrace("Global hooks array is not an array!\n");
+               throw new MWException("Global hooks array is not an array!\n");
                return false;
        }
 
@@ -43,7 +43,7 @@ function wfRunHooks($event, $args = null) {
        }
 
        if (!is_array($wgHooks[$event])) {
-               wfDebugDieBacktrace("Hooks array for event '$event' is not an array!\n");
+               throw new MWException("Hooks array for event '$event' is not an array!\n");
                return false;
        }
 
@@ -62,7 +62,7 @@ function wfRunHooks($event, $args = null) {
 
                if (is_array($hook)) {
                        if (count($hook) < 1) {
-                               wfDebugDieBacktrace("Empty array in hooks for " . $event . "\n");
+                               throw new MWException("Empty array in hooks for " . $event . "\n");
                        } else if (is_object($hook[0])) {
                                $object =& $wgHooks[$event][$index][0];
                                if (count($hook) < 2) {
@@ -82,7 +82,7 @@ function wfRunHooks($event, $args = null) {
                                }
                        } else {
                                var_dump( $wgHooks );
-                               wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n");
+                               throw new MWException("Unknown datatype in hooks for " . $event . "\n");
                        }
                } else if (is_string($hook)) { # functions look like strings, too
                        $func = $hook;
@@ -90,7 +90,7 @@ function wfRunHooks($event, $args = null) {
                        $object =& $wgHooks[$event][$index];
                        $method = "on" . $event;
                } else {
-                       wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n");
+                       throw new MWException("Unknown datatype in hooks for " . $event . "\n");
                }
 
                /* We put the first data element on, if needed. */
@@ -119,7 +119,7 @@ function wfRunHooks($event, $args = null) {
 
                if (is_string($retval)) {
                        global $wgOut;
-                       $wgOut->fatalError($retval);
+                       $wgOut->showFatalError($retval);
                        return false;
                } else if (!$retval) {
                        return false;
index 8e6cf43..9f4fc7f 100644 (file)
@@ -75,7 +75,7 @@ class Image
 
        function Image( $title ) {
                if( !is_object( $title ) ) {
-                       wfDebugDieBacktrace( 'Image constructor given bogus title.' );
+                       throw new MWException( 'Image constructor given bogus title.' );
                }
                $this->title =& $title;
                $this->name = $title->getDBkey();
@@ -994,7 +994,7 @@ class Image
                                                        unlink( $thumbPath );
                                                } else {
                                                        // This should have been dealt with already
-                                                       wfDebugDieBacktrace( "Directory where image should be: $thumbPath" );
+                                                       throw new MWException( "Directory where image should be: $thumbPath" );
                                                }
                                        }
                                        // Rename the old image into the new location
@@ -1270,16 +1270,24 @@ class Image
                }
                # img_name must be unique
                if ( !$db->indexUnique( 'image', 'img_name' ) && !$db->indexExists('image','PRIMARY') ) {
-                       wfDebugDieBacktrace( 'Database schema not up to date, please run maintenance/archives/patch-image_name_unique.sql' );
+                       throw new MWException( 'Database schema not up to date, please run maintenance/archives/patch-image_name_unique.sql' );
                }
 
-               #new fields must exist
+               # new fields must exist
+               # 
+               # Not really, there's hundreds of checks like this that we could do and they're all pointless, because 
+               # if the fields are missing, the database will loudly report a query error, the first time you try to do 
+               # something. The only reason I put the above schema check in was because the absence of that particular
+               # index would lead to an annoying subtle bug. No error message, just some very odd behaviour on duplicate
+               # uploads. -- TS
+               /*
                if ( !$db->fieldExists( 'image', 'img_media_type' )
                  || !$db->fieldExists( 'image', 'img_metadata' )
                  || !$db->fieldExists( 'image', 'img_width' ) ) {
 
-                       wfDebugDieBacktrace( 'Database schema not up to date, please run maintenance/update.php' );
-               }
+                       throw new MWException( 'Database schema not up to date, please run maintenance/update.php' );
+                }
+                */
        }
 
        /**
index 53ecd86..08528f5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if ( ! defined( 'MEDIAWIKI' ) )
-       die( -1 );
+       die( 1 );
 
 /**
  * @package MediaWiki
index 3c31e95..244f7c0 100644 (file)
@@ -7,7 +7,7 @@
  *
  */
 if( !defined( 'MEDIAWIKI' ) )
-       die( -1 );
+       die( 1 );
 
 require_once( 'Image.php' );
 
@@ -453,7 +453,7 @@ END
                $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
                if ( ( !is_null( $image ) )
                  && ( '' == trim( $image ) ) ) {
-                       $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
+                       $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
                        return;
                }
 
@@ -464,7 +464,7 @@ END
                        if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
                                $this->doDelete();
                        } else {
-                               $wgOut->fatalError( wfMsg( 'sessionfailure' ) );
+                               $wgOut->showFatalError( wfMsg( 'sessionfailure' ) );
                        }
                        return;
                }
@@ -492,11 +492,11 @@ END
 
                if ( !is_null( $oldimage ) ) {
                        if ( strlen( $oldimage ) < 16 ) {
-                               $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+                               $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
                                return;
                        }
                        if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
-                               $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+                               $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
                                return;
                        }
 
@@ -511,7 +511,9 @@ END
                                );
                                wfPurgeSquidServers($urlArr);
                        }
-                       $this->doDeleteOldImage( $oldimage );
+                       if ( !$this->doDeleteOldImage( $oldimage ) ) {
+                               return;
+                       }
                        $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
                        $deleted = $oldimage;
                } else {
@@ -524,7 +526,7 @@ END
                        $targetFile = "{$dest}/{$image}";
                        if( file_exists( $targetFile ) && ! @unlink( $targetFile ) ) {
                                # If the deletion operation actually failed, bug out:
-                               $wgOut->fileDeleteError( $targetFile );
+                               $wgOut->showFileDeleteError( $targetFile );
                                return;
                        }
                        $dbw->delete( 'image', array( 'img_name' => $image ) );
@@ -541,7 +543,9 @@ END
                        # Purge archive URLs from the squid
                        $urlArr = Array();
                        while ( $s = $dbw->fetchObject( $res ) ) {
-                               $this->doDeleteOldImage( $s->oi_archive_name );
+                               if ( !$this->doDeleteOldImage( $s->oi_archive_name ) ) {
+                                       return;
+                               }
                                $urlArr[] = wfImageArchiveUrl( $s->oi_archive_name );
                        }
 
@@ -581,6 +585,9 @@ END
                $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
        }
 
+       /**
+        * @return success
+        */
        function doDeleteOldImage( $oldimage )
        {
                global $wgOut;
@@ -598,11 +605,13 @@ END
                $targetFile = "{$archive}/{$oldimage}";
                if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) {
                        # If we actually have a file and can't delete it, throw an error.
-                       $wgOut->fileDeleteError( "{$archive}/{$oldimage}" );
+                       $wgOut->showFileDeleteError( "{$archive}/{$oldimage}" );
+                       return false;
                } else {
                        # Log the deletion
                        $log = new LogPage( 'delete' );
                        $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
+                       return true;
                }
        }
 
@@ -611,11 +620,11 @@ END
 
                $oldimage = $wgRequest->getText( 'oldimage' );
                if ( strlen( $oldimage ) < 16 ) {
-                       $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+                       $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
                        return;
                }
                if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
-                       $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
+                       $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
                        return;
                }
 
@@ -624,7 +633,7 @@ END
                        return;
                }
                if( $wgUser->isAnon() ) {
-                       $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
+                       $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
                        return;
                }
                if ( ! $this->mTitle->userCanEdit() ) {
@@ -635,7 +644,7 @@ END
                        return $this->blockedIPpage();
                }
                if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
-                       $wgOut->errorpage( 'internalerror', 'sessionfailure' );
+                       $wgOut->showErrorPage( 'internalerror', 'sessionfailure' );
                        return;
                }
                $name = substr( $oldimage, 15 );
@@ -645,7 +654,7 @@ END
                $curfile = "{$dest}/{$name}";
 
                if ( ! is_file( $curfile ) ) {
-                       $wgOut->fileNotFoundError( htmlspecialchars( $curfile ) );
+                       $wgOut->showFileNotFoundError( htmlspecialchars( $curfile ) );
                        return;
                }
                $oldver = wfTimestampNow() . "!{$name}";
@@ -654,11 +663,12 @@ END
                $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage )  );
 
                if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
-                       $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" );
+                       $wgOut->showFileRenameError( $curfile, "${archive}/{$oldver}" );
                        return;
                }
                if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) {
-                       $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile );
+                       $wgOut->showFileCopyError( "${archive}/{$oldimage}", $curfile );
+                       return;
                }
 
                # Record upload and update metadata cache
index 12cd4bc..8a19462 100644 (file)
@@ -194,7 +194,7 @@ class Linker {
 
                # Fail gracefully
                if ( ! is_object($nt) ) {
-                       # wfDebugDieBacktrace();
+                       # throw new MWException();
                        wfProfileOut( $fname );
                        return "<!-- ERROR -->{$prefix}{$text}{$trail}";
                }
@@ -343,7 +343,7 @@ class Linker {
        function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                # Fail gracefully
                if ( ! isset($nt) ) {
-                       # wfDebugDieBacktrace();
+                       # throw new MWException();
                        return "<!-- ERROR -->{$prefix}{$text}{$trail}";
                }
 
@@ -658,7 +658,7 @@ class Linker {
        function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                # Fail gracefully
                if ( ! isset($nt) ) {
-                       # wfDebugDieBacktrace();
+                       # throw new MWException();
                        return "<!-- ERROR -->{$prefix}{$text}{$trail}";
                }
 
index 5472858..caa1c97 100644 (file)
@@ -44,7 +44,7 @@ class LinksUpdate {
                $this->mDb =& wfGetDB( DB_MASTER );
 
                if ( !is_object( $title ) ) {
-                       wfDebugDieBacktrace( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
+                       throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
                                "Please see Article::editUpdates() for an invocation example.\n" );
                }
                $this->mTitle = $title;
index a2e08f7..e015bb7 100644 (file)
@@ -192,7 +192,7 @@ class MagicWord {
                global $wgMagicWords;
 
                if ( !is_array( $wgMagicWords ) ) {
-                       wfDebugDieBacktrace( "Incorrect initialisation order, \$wgMagicWords does not exist\n" );
+                       throw new MWException( "Incorrect initialisation order, \$wgMagicWords does not exist\n" );
                }
                if (!array_key_exists( $id, $wgMagicWords ) ) {
                        $mw = new MagicWord();
index 083e220..ed9e5ec 100644 (file)
@@ -291,7 +291,7 @@ class MessageCache {
                $fname = 'MessageCache::loadFromDB';
                $dbr =& wfGetDB( DB_SLAVE );
                if ( !$dbr ) {
-                       wfDebugDieBacktrace( 'Invalid database object' );
+                       throw new MWException( 'Invalid database object' );
                }
                $conditions = array( 'page_is_redirect' => 0,
                                        'page_namespace' => NS_MEDIAWIKI);
index e78c072..b717292 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if ( ! defined( 'MEDIAWIKI' ) )
-       die( -1 );
+       die( 1 );
 /**
  * @package MediaWiki
  */
@@ -666,7 +666,7 @@ class OutputPage {
        /**
         * Note: these arguments are keys into wfMsg(), not text!
         */
-       function errorpage( $title, $msg ) {
+       function showErrorPage( $title, $msg ) {
                global $wgTitle;
 
                $this->mDebugtext .= 'Original title: ' .
@@ -681,11 +681,13 @@ class OutputPage {
                $this->mBodytext = '';
                $this->addWikiText( wfMsg( $msg ) );
                $this->returnToMain( false );
-
-               $this->output();
-               wfErrorExit();
        }
 
+       /** @obsolete */
+       function errorpage( $title, $msg ) {
+               throw new ErrorPageError( $title, $msg );
+       }
+               
        /**
         * Display an error page indicating that a given version of MediaWiki is
         * required to use it
@@ -779,34 +781,9 @@ class OutputPage {
                $this->returnToMain();
        }
 
+       /** @obsolete */
        function databaseError( $fname, $sql, $error, $errno ) {
-               global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
-
-               $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
-               $this->setRobotpolicy( 'noindex,nofollow' );
-               $this->setArticleRelated( false );
-               $this->enableClientCache( false );
-               $this->mRedirect = '';
-
-               if( !$wgShowSQLErrors ) {
-                       $sql = wfMsg( 'sqlhidden' );
-               }
-
-               if ( $wgCommandLineMode ) {
-                       $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
-                                               htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
-               } else {
-                       $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
-                                               htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
-               }
-
-               if ( $wgCommandLineMode || !is_object( $wgUser )) {
-                       print $msg."\n";
-                       wfErrorExit();
-               }
-               $this->mBodytext = $msg;
-               $this->output();
-               wfErrorExit();
+               throw new MWException( "OutputPage::databaseError is obsolete\n" );
        }
 
        function readOnlyPage( $source = null, $protected = false ) {
@@ -857,36 +834,63 @@ class OutputPage {
                $this->returnToMain( false );
        }
 
-       function fatalError( $message ) {
+       /** @obsolete */
+       function fatalError( $message ) { 
+               throw new FatalError( $message ); 
+       }
+       
+       /** @obsolete */
+       function unexpectedValueError( $name, $val ) {
+               throw new FatalError( wfMsg( 'unexpected', $name, $val ) );
+       }
+
+       /** @obsolete */
+       function fileCopyError( $old, $new ) {
+               throw new FatalError( wfMsg( 'filecopyerror', $old, $new ) );
+       }
+
+       /** @obsolete */
+       function fileRenameError( $old, $new ) {
+               throw new FatalError( wfMsg( 'filerenameerror', $old, $new ) );
+       }
+
+       /** @obsolete */
+       function fileDeleteError( $name ) {
+               throw new FatalError( wfMsg( 'filedeleteerror', $name ) );
+       }
+
+       /** @obsolete */
+       function fileNotFoundError( $name ) {
+               throw new FatalError( wfMsg( 'filenotfound', $name ) );
+       }
+
+       function showFatalError( $message ) {
                $this->setPageTitle( wfMsg( "internalerror" ) );
                $this->setRobotpolicy( "noindex,nofollow" );
                $this->setArticleRelated( false );
                $this->enableClientCache( false );
                $this->mRedirect = '';
-
                $this->mBodytext = $message;
-               $this->output();
-               wfErrorExit();
        }
 
-       function unexpectedValueError( $name, $val ) {
-               $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
+       function showUnexpectedValueError( $name, $val ) {
+               $this->showFatalError( wfMsg( 'unexpected', $name, $val ) );
        }
 
-       function fileCopyError( $old, $new ) {
-               $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
+       function showFileCopyError( $old, $new ) {
+               $this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) );
        }
 
-       function fileRenameError( $old, $new ) {
-               $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
+       function showFileRenameError( $old, $new ) {
+               $this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) );
        }
 
-       function fileDeleteError( $name ) {
-               $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
+       function showFileDeleteError( $name ) {
+               $this->showFatalError( wfMsg( 'filedeleteerror', $name ) );
        }
 
-       function fileNotFoundError( $name ) {
-               $this->fatalError( wfMsg( 'filenotfound', $name ) );
+       function showFileNotFoundError( $name ) {
+               $this->showFatalError( wfMsg( 'filenotfound', $name ) );
        }
 
        /**
index 61de1bf..d1f48cf 100644 (file)
@@ -471,7 +471,7 @@ class Parser
                                                $output = call_user_func_array( $this->mTagHooks[$tagName],
                                                        array( $content, $params, $this ) );
                                        } else {
-                                               wfDebugDieBacktrace( "Invalid call hook $element" );
+                                               throw new MWException( "Invalid call hook $element" );
                                        }
                                }
                        } else {
@@ -1329,7 +1329,7 @@ class Parser
                $useLinkPrefixExtension = $wgContLang->linkPrefixExtension();
 
                if( is_null( $this->mTitle ) ) {
-                       wfDebugDieBacktrace( 'nooo' );
+                       throw new MWException( 'nooo' );
                }
                $nottalk = !$this->mTitle->isTalkPage();
 
@@ -2119,7 +2119,7 @@ class Parser
                                }
                                break;
                        default:
-                               wfDebugDieBacktrace( "State machine error in $fname" );
+                               throw new MWException( "State machine error in $fname" );
                        }
                }
                if( $stack > 0 ) {
index 1da49dc..2a40a37 100644 (file)
@@ -65,7 +65,7 @@ class ProtectionForm {
                if( is_null( $this->mTitle ) ||
                        !$this->mTitle->exists() ||
                        $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                       $wgOut->fatalError( wfMsg( 'badarticleerror' ) );
+                       $wgOut->showFatalError( wfMsg( 'badarticleerror' ) );
                        return;
                }
 
@@ -98,13 +98,12 @@ class ProtectionForm {
 
                $token = $wgRequest->getVal( 'wpEditToken' );
                if( !$wgUser->matchEditToken( $token ) ) {
-                       $wgOut->fatalError( wfMsg( 'sessionfailure' ) );
-                       return false;
+                       throw new FatalError( wfMsg( 'sessionfailure' ) );
                }
 
                $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason );
                if( !$ok ) {
-                       $wgOut->fatalError( "Unknown error at restriction save time." );
+                       throw new FatalError( "Unknown error at restriction save time." );
                }
                return $ok;
        }
index 3e3cef4..b2f8e18 100644 (file)
@@ -284,7 +284,7 @@ class Revision {
                        $this->mTitle     = null; # Load on demand if needed
                        $this->mCurrent   = false;
                } else {
-                       wfDebugDieBacktrace( 'Revision constructor passed invalid row format.' );
+                       throw new MWException( 'Revision constructor passed invalid row format.' );
                }
        }
 
@@ -606,7 +606,7 @@ class Revision {
                        $data = ExternalStore::insert( $store, $data );
                        if ( !$data ) {
                                # This should only happen in the case of a configuration error, where the external store is not valid
-                               wfDebugDieBacktrace( "Unable to store text to external storage $store" );
+                               throw new MWException( "Unable to store text to external storage $store" );
                        }
                        if ( $flags ) {
                                $flags .= ',';
index ca7831a..00b9690 100644 (file)
@@ -742,7 +742,7 @@ class Sanitizer {
                        # For 'reduced' form, return explicitly the attribute name here.
                        return $set[1];
                } else {
-                       wfDebugDieBacktrace( "Tag conditions not met. This should never happen and is a bug." );
+                       throw new MWException( "Tag conditions not met. This should never happen and is a bug." );
                }
        }
 
index b5480d6..acdca9c 100644 (file)
@@ -19,7 +19,7 @@ if( defined( 'MEDIAWIKI' ) ) {
 // Check to see if we are at the file scope
 if ( !isset( $wgVersion ) ) {
        echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
-       die( -1 );
+       die( 1 );
 }
 
 if( !isset( $wgProfiling ) )
index 5bf36ab..dc14640 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if ( ! defined( 'MEDIAWIKI' ) )
-       die( -1 );
+       die( 1 );
 
 /**
  *
index f09667d..f9fcd2e 100644 (file)
@@ -157,13 +157,13 @@ function wfSpecialContributions( $par = null ) {
 
        $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
        if (!strlen($target)) {
-               $wgOut->errorpage('notargettitle', 'notargettext');
+               $wgOut->showErrorPage('notargettitle', 'notargettext');
                return;
        }
 
        $nt = Title::newFromURL( $target );
        if (!$nt) {
-               $wgOut->errorpage( 'notargettitle', 'notargettext' );
+               $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                return;
        }
 
index 78ea5c3..c66389e 100644 (file)
@@ -14,13 +14,13 @@ function wfSpecialEmailuser( $par ) {
        global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgEnableUserEmail;
 
        if( !( $wgEnableEmail && $wgEnableUserEmail ) ) {
-               $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
+               $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" );
                return;
        }
 
        if( !$wgUser->canSendEmail() ) {
                wfDebug( "User can't send.\n" );
-               $wgOut->errorpage( "mailnologin", "mailnologintext" );
+               $wgOut->showErrorPage( "mailnologin", "mailnologintext" );
                return;
        }
 
@@ -28,21 +28,21 @@ function wfSpecialEmailuser( $par ) {
        $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
        if ( "" == $target ) {
                wfDebug( "Target is empty.\n" );
-               $wgOut->errorpage( "notargettitle", "notargettext" );
+               $wgOut->showErrorPage( "notargettitle", "notargettext" );
                return;
        }
 
        $nt = Title::newFromURL( $target );
        if ( is_null( $nt ) ) {
                wfDebug( "Target is invalid title.\n" );
-               $wgOut->errorpage( "notargettitle", "notargettext" );
+               $wgOut->showErrorPage( "notargettitle", "notargettext" );
                return;
        }
 
        $nu = User::newFromName( $nt->getText() );
        if( is_null( $nu ) || !$nu->canReceiveEmail() ) {
                wfDebug( "Target is invalid user or can't receive.\n" );
-               $wgOut->errorpage( "noemailtitle", "noemailtext" );
+               $wgOut->showErrorPage( "noemailtitle", "noemailtext" );
                return;
        }
 
index 3c153f9..38d715b 100644 (file)
@@ -94,7 +94,7 @@ END
                $fp = fopen( $wgReadOnlyFile, 'w' );
 
                if ( false === $fp ) {
-                       $wgOut->fileNotFoundError( $wgReadOnlyFile );
+                       $wgOut->showFileNotFoundError( $wgReadOnlyFile );
                        return;
                }
                fwrite( $fp, $this->reason );
index 4f795c2..2c0720d 100644 (file)
@@ -13,7 +13,7 @@ function wfSpecialMovepage( $par = null ) {
 
        # check rights. We don't want newbies to move pages to prevents possible attack
        if ( !$wgUser->isAllowed( 'move' ) or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
-               $wgOut->errorpage( "movenologin", "movenologintext" );
+               $wgOut->showErrorPage( "movenologin", "movenologintext" );
                return;
        }
        # We don't move protected pages
@@ -60,7 +60,7 @@ class MovePageForm {
 
                $ot = Title::newFromURL( $this->oldTitle );
                if( is_null( $ot ) ) {
-                       $wgOut->errorpage( 'notargettitle', 'notargettext' );
+                       $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
                $oldTitle = $ot->getPrefixedText();
index ac7e0e2..fc7efaf 100644 (file)
@@ -293,7 +293,7 @@ class SpecialPage
                                        $wgOut->setArticleRelated( false );
                                        $wgOut->setRobotpolicy( 'noindex,nofollow' );
                                        $wgOut->setStatusCode( 404 );
-                                       $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' );
+                                       $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
                                        $retVal = false;
                                }
                        }
index bccbc6e..1ade307 100644 (file)
@@ -104,7 +104,7 @@ class PreferencesForm {
                global $wgUser, $wgOut;
 
                if ( $wgUser->isAnon() ) {
-                       $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
+                       $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' );
                        return;
                }
                if ( wfReadOnly() ) {
index cf37647..f14e07b 100644 (file)
@@ -19,7 +19,7 @@ function wfSpecialRevisiondelete( $par = null ) {
        $page = Title::newFromUrl( $target );
        
        if( is_null( $page ) ) {
-               $wgOut->errorpage( 'notargettitle', 'notargettext' );
+               $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                return;
        }
        
index d167365..ade8d75 100644 (file)
@@ -28,7 +28,7 @@ class PageArchive {
 
        function PageArchive( &$title ) {
                if( is_null( $title ) ) {
-                       wfDebugDieBacktrace( 'Archiver() given a null title.');
+                       throw new MWException( 'Archiver() given a null title.');
                }
                $this->title =& $title;
        }
@@ -566,7 +566,7 @@ class UndeleteForm {
                                return true;
                        }
                }
-               $wgOut->fatalError( wfMsg( "cannotundelete" ) );
+               $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
                return false;
        }
 }
index 9d13808..a10d1ee 100644 (file)
@@ -84,7 +84,7 @@ END
                        return;
                }
                if ( @! unlink( $wgReadOnlyFile ) ) {
-                       $wgOut->fileDeleteError( $wgReadOnlyFile );
+                       $wgOut->showFileDeleteError( $wgReadOnlyFile );
                        return;
                }
                $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
index e61f485..7311721 100644 (file)
@@ -99,7 +99,7 @@ class UploadForm {
 
                # Check uploading enabled
                if( !$wgEnableUploads ) {
-                       $wgOut->errorPage( 'uploaddisabled', 'uploaddisabledtext' );
+                       $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' );
                        return;
                }
 
@@ -110,7 +110,7 @@ class UploadForm {
                                return;
                        }
                } else {
-                       $wgOut->errorPage( 'uploadnologin', 'uploadnologintext' );
+                       $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
                        return;
                }
 
@@ -132,7 +132,9 @@ class UploadForm {
                }
 
                if( $this->mReUpload ) {
-                       $this->unsaveUploadedFile();
+                       if ( !$this->unsaveUploadedFile() ) {
+                               return;
+                       }
                        $this->mainUploadForm();
                } else if ( 'submit' == $this->mAction || $this->mUpload ) {
                        $this->processUpload();
@@ -343,7 +345,7 @@ class UploadForm {
                        } else {
                                // Image::recordUpload() fails if the image went missing, which is
                                // unlikely, hence the lack of a specialised message
-                               $wgOut->fileNotFoundError( $this->mUploadSaveName );
+                               $wgOut->showFileNotFoundError( $this->mUploadSaveName );
                        }
                }
        }
@@ -376,7 +378,7 @@ class UploadForm {
                        wfRestoreWarnings();
 
                        if( ! $success ) {
-                               $wgOut->fileRenameError( $this->mSavedFile,
+                               $wgOut->showFileRenameError( $this->mSavedFile,
                                  "${archive}/{$this->mUploadOldVersion}" );
                                return false;
                        }
@@ -393,7 +395,7 @@ class UploadForm {
                wfRestoreWarnings();
 
                if( ! $success ) {
-                       $wgOut->fileCopyError( $tempName, $this->mSavedFile );
+                       $wgOut->showFileCopyError( $tempName, $this->mSavedFile );
                        return false;
                } else {
                        wfDebug("$fname: wrote tempfile $tempName to ".$this->mSavedFile."\n");
@@ -424,7 +426,7 @@ class UploadForm {
                        ? rename( $tempName, $stash )
                        : move_uploaded_file( $tempName, $stash );
                if ( !$success ) {
-                       $wgOut->fileCopyError( $tempName, $stash );
+                       $wgOut->showFileCopyError( $tempName, $stash );
                        return false;
                }
 
@@ -460,6 +462,7 @@ class UploadForm {
        /**
         * Remove a temporarily kept file stashed by saveTempUploadedFile().
         * @access private
+        * @return success
         */
        function unsaveUploadedFile() {
                global $wgOut;
@@ -467,7 +470,10 @@ class UploadForm {
                $success = unlink( $this->mUploadTempName );
                wfRestoreWarnings();
                if ( ! $success ) {
-                       $wgOut->fileDeleteError( $this->mUploadTempName );
+                       $wgOut->showFileDeleteError( $this->mUploadTempName );
+                       return false;
+               } else {
+                       return true;
                }
        }
 
index a303e8c..51a6dd2 100644 (file)
@@ -42,7 +42,7 @@ class UploadFormMogile extends UploadForm {
                if( $mfs->getPaths( $this->mSavedFile )) {
                        $this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}";
                        if( !$mfs->rename( $this->mSavedFile, "archive!{$this->mUploadOldVersion}" ) ) {
-                               $wgOut->fileRenameError( $this->mSavedFile,
+                               $wgOut->showFileRenameError( $this->mSavedFile,
                                  "archive!{$this->mUploadOldVersion}" );
                                return false;
                        }
@@ -52,12 +52,12 @@ class UploadFormMogile extends UploadForm {
 
                if ( $this->mStashed ) {
                        if (!$mfs->rename($tempName,$this->mSavedFile)) {
-                               $wgOut->fileRenameError($tempName, $this->mSavedFile );
+                               $wgOut->showFileRenameError($tempName, $this->mSavedFile );
                                return false;
                        }
                } else {
                        if ( !$mfs->saveFile($this->mSavedFile,'normal',$tempName )) {
-                               $wgOut->fileCopyError( $tempName, $this->mSavedFile );
+                               $wgOut->showFileCopyError( $tempName, $this->mSavedFile );
                                return false;
                        }
                        unlink($tempName);
@@ -83,7 +83,7 @@ class UploadFormMogile extends UploadForm {
                $stash = 'stash!' . gmdate( "YmdHis" ) . '!' . $saveName;
                $mfs = MogileFS::NewMogileFS();
                if ( !$mfs->saveFile( $stash, 'normal', $tempName ) ) {
-                       $wgOut->fileCopyError( $tempName, $stash );
+                       $wgOut->showFileCopyError( $tempName, $stash );
                        return false;
                }
                unlink($tempName);
@@ -119,12 +119,16 @@ class UploadFormMogile extends UploadForm {
        /**
         * Remove a temporarily kept file stashed by saveTempUploadedFile().
         * @access private
+        * @return success
         */
        function unsaveUploadedFile() {
                global $wgOut;
                $mfs = MogileFS::NewMogileFS();
                if ( ! $mfs->delete( $this->mUploadTempName ) ) {
-                       $wgOut->fileDeleteError( $this->mUploadTempName );
+                       $wgOut->showFileDeleteError( $this->mUploadTempName );
+                       return false;
+               } else {
+                       return true;
                }
        }
 }
index 41465dd..7f072bd 100644 (file)
@@ -43,13 +43,13 @@ class WhatLinksHerePage {
                $targetString = isset($this->par) ? $this->par : $this->request->getVal( 'target' );
 
                if (is_null($targetString)) {
-                       $wgOut->errorpage( 'notargettitle', 'notargettext' );
+                       $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
 
                $this->target = Title::newFromURL( $targetString );
                if( !$this->target ) {
-                       $wgOut->errorpage( 'notargettitle', 'notargettext' );
+                       $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
                $this->selfTitle = Title::makeTitleSafe( NS_SPECIAL,
index 21676c0..82b5539 100644 (file)
@@ -109,7 +109,7 @@ class Title {
                $fname = 'Title::newFromText';
 
                if( is_object( $text ) ) {
-                       wfDebugDieBacktrace( 'Title::newFromText given an object' );
+                       throw new MWException( 'Title::newFromText given an object' );
                }
 
                /**
index 9aed0bf..f695d1d 100644 (file)
@@ -1192,7 +1192,7 @@ class User {
         * @deprecated
         */
        function isSysop() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isSysop() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isSysop() method\n" );
                #return $this->isAllowed( 'protect' );
        }
 
@@ -1201,7 +1201,7 @@ class User {
         * @deprecated
         */
        function isDeveloper() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
                #return $this->isAllowed( 'siteadmin' );
        }
 
@@ -1210,7 +1210,7 @@ class User {
         * @deprecated
         */
        function isBureaucrat() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
                #return $this->isAllowed( 'makesysop' );
        }
 
index 736e215..4031e36 100644 (file)
@@ -452,7 +452,7 @@ class FauxRequest extends WebRequest {
                if( is_array( $data ) ) {
                        $this->data = $data;
                } else {
-                       wfDebugDieBacktrace( "FauxRequest() got bogus data" );
+                       throw new MWException( "FauxRequest() got bogus data" );
                }
                $this->wasPosted = $wasPosted;
        }
@@ -479,11 +479,11 @@ class FauxRequest extends WebRequest {
        }
 
        function getRequestURL() {
-               wfDebugDieBacktrace( 'FauxRequest::getRequestURL() not implemented' );
+               throw new MWException( 'FauxRequest::getRequestURL() not implemented' );
        }
 
        function appendQuery( $query ) {
-               wfDebugDieBacktrace( 'FauxRequest::appendQuery() not implemented' );
+               throw new MWException( 'FauxRequest::appendQuery() not implemented' );
        }
 
 }
index 682b76a..e9cdff4 100644 (file)
@@ -51,7 +51,7 @@ class MediaWiki {
                        } elseif( is_string( $article ) ) {
                                $output->redirect( $article );
                        } else {
-                               wfDebugDieBacktrace( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" );
+                               throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" );
                        }
                }
                wfProfileOut( 'MediaWiki::initialize' );
@@ -129,7 +129,8 @@ class MediaWiki {
                        wfSpecialSearch();
                } else if( !$title or $title->getDBkey() == '' ) {
                        $title = Title::newFromText( wfMsgForContent( 'badtitle' ) );
-                       $output->errorpage( 'badtitle', 'badtitletext' );
+                       # Die now before we mess up $wgArticle and the skin stops working
+                       throw new ErrorPageError( 'badtitle', 'badtitletext' );
                } else if ( $title->getInterwiki() != '' ) {
                        if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
                                $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
@@ -141,7 +142,7 @@ class MediaWiki {
                                $output->redirect( $url );
                        } else {
                                $title = Title::newFromText( wfMsgForContent( 'badtitle' ) );
-                               $output->errorpage( 'badtitle', 'badtitletext' );
+                               throw new ErrorPageError( 'badtitle', 'badtitletext' );
                        }
                } else if ( ( $action == 'view' ) &&
                        (!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
@@ -392,7 +393,7 @@ class MediaWiki {
                                break;
                        default:
                                if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
-                                       $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
+                                       $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
                                }
                }
                wfProfileOut( 'MediaWiki::performAction' );