[BUGFIX] Throw correct Exceptions everywhere
authorSteffen Gebert <steffen.gebert@typo3.org>
Mon, 7 Mar 2011 16:13:25 +0000 (17:13 +0100)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Tue, 8 Mar 2011 17:32:48 +0000 (18:32 +0100)
Improve the way, TYPO3 is throwing Exceptions:

* Add a unique error code to all Exception($msg, $code) calls
* Replace die() statements with Exceptions, if possible
* Replace some general Exceptions with RuntimeException or ArgumentException.

Change-Id: Ic148f14b9a71136c917e9dc8b95513341b3c6ca0
Resolves: #M16953
Reviewed-on: http://review.typo3.org/1079
Reviewed-by: Andreas Wolf <andreas.wolf@ikt-werk.de>
Tested-by: Andreas Wolf <andreas.wolf@ikt-werk.de>
Reviewed-by: Steffen Ritter <info@rs-websystems.de>
39 files changed:
t3lib/class.t3lib_beuserauth.php
t3lib/class.t3lib_db.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_extmgm.php
t3lib/class.t3lib_lock.php
t3lib/class.t3lib_spritemanager.php
t3lib/class.t3lib_treeview.php
t3lib/class.t3lib_tsparser.php
t3lib/class.t3lib_userauthgroup.php
t3lib/extjs/class.t3lib_extjs_extdirectrouter.php
t3lib/formprotection/class.t3lib_formprotection_abstract.php
t3lib/mail/class.t3lib_mail_mailer.php
t3lib/mail/class.t3lib_mail_mboxtransport.php
t3lib/tree/class.t3lib_tree_node.php
t3lib/tree/class.t3lib_tree_nodecollection.php
t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php
t3lib/tree/tca/class.t3lib_tree_tca_dataproviderfactory.php
typo3/db_list.php
typo3/file_edit.php
typo3/file_list.php
typo3/file_newfolder.php
typo3/file_rename.php
typo3/file_upload.php
typo3/index.php
typo3/init.php
typo3/mod.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_pagegen.php
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/cms/tslib/showpic.php
typo3/sysext/install/mod/class.tx_install.php
typo3/sysext/install/mod/class.tx_install_session.php
typo3/sysext/lang/lang.php
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php
typo3/sysext/scheduler/mod1/index.php
typo3/sysext/simulatestatic/class.tx_simulatestatic.php
typo3/wizard_forms.php
typo3/wizard_table.php

index ee75e53..f590b7a 100644 (file)
@@ -181,10 +181,10 @@ class t3lib_beUserAuth extends t3lib_userAuthGroup {
                                        $this->backendSetUC(); // Setting the UC array. It's needed with fetchGroupData first, due to default/overriding of values.
                                        $this->emailAtLogin(); // email at login - if option set.
                                } else {
-                                       throw new RuntimeException('Login Error: TYPO3 is in maintenance mode at the moment. Only administrators are allowed access.');
+                                       throw new RuntimeException('Login Error: TYPO3 is in maintenance mode at the moment. Only administrators are allowed access.', 1294585860);
                                }
                        } else {
-                               throw new RuntimeException('Login Error: IP locking prevented you from being authorized. Can\'t proceed, sorry.');
+                               throw new RuntimeException('Login Error: IP locking prevented you from being authorized. Can\'t proceed, sorry.', 1294585861);
                        }
                }
        }
index fb979e3..118cdcb 100644 (file)
@@ -694,7 +694,7 @@ class t3lib_DB {
        public function listQuery($field, $value, $table) {
                $value = (string) $value;
                if (strpos(',', $value) !== FALSE) {
-                       throw new InvalidArgumentException('$value must not contain a comma (,) in $this->listQuery() !');
+                       throw new InvalidArgumentException('$value must not contain a comma (,) in $this->listQuery() !', 1294585862);
                }
                $pattern = $this->quoteStr($value, $table);
                $where = 'FIND_IN_SET(\'' . $pattern . '\',' . $field . ')';
index 2edfb73..8e09d16 100644 (file)
@@ -4888,7 +4888,7 @@ final class t3lib_div {
                ) {
                        $errorMsg = "Function/class '$funcRef' was not prepended with '$checkPrefix'";
                        if ($errorMode == 2) {
-                               throw new Exception($errorMsg);
+                               throw new InvalidArgumentException($errorMsg, 1294585864);
                        } elseif (!$errorMode) {
                                debug($errorMsg, 't3lib_div::callUserFunction');
                        }
@@ -4927,17 +4927,17 @@ final class t3lib_div {
                                                array(&$params, &$ref)
                                        );
                                } else {
-                                       $errorMsg = "<strong>ERROR:</strong> No method name '" . $parts[1] . "' in class " . $parts[0];
+                                       $errorMsg = "No method name '" . $parts[1] . "' in class " . $parts[0];
                                        if ($errorMode == 2) {
-                                               throw new Exception($errorMsg);
+                                               throw new InvalidArgumentException($errorMsg, 1294585865);
                                        } elseif (!$errorMode) {
                                                debug($errorMsg, 't3lib_div::callUserFunction');
                                        }
                                }
                        } else {
-                               $errorMsg = "<strong>ERROR:</strong> No class named: " . $parts[0];
+                               $errorMsg = 'No class named ' . $parts[0];
                                if ($errorMode == 2) {
-                                       throw new Exception($errorMsg);
+                                       throw new InvalidArgumentException($errorMsg, 1294585866);
                                } elseif (!$errorMode) {
                                        debug($errorMsg, 't3lib_div::callUserFunction');
                                }
@@ -4946,9 +4946,9 @@ final class t3lib_div {
                        if (function_exists($funcRef)) {
                                $content = call_user_func_array($funcRef, array(&$params, &$ref));
                        } else {
-                               $errorMsg = "<strong>ERROR:</strong> No function named: " . $funcRef;
+                               $errorMsg = 'No function named: ' . $funcRef;
                                if ($errorMode == 2) {
-                                       throw new Exception($errorMsg);
+                                       throw new InvalidArgumentException($errorMsg, 1294585867);
                                } elseif (!$errorMode) {
                                        debug($errorMsg, 't3lib_div::callUserFunction');
                                }
index 398a618..9bfd16f 100644 (file)
@@ -235,7 +235,7 @@ final class t3lib_extMgm {
         */
        public static function getExtensionVersion($key) {
                if (!is_string($key) || empty($key)) {
-                       throw new InvalidArgumentException('Extension key must be a non-empty string.');
+                       throw new InvalidArgumentException('Extension key must be a non-empty string.', 1294586096);
                }
                if (!self::isLoaded($key)) {
                        return '';
index f734e9e..bb34615 100644 (file)
@@ -83,7 +83,7 @@ class t3lib_lock {
                if (in_array($method, array('disable', 'simple', 'flock', 'semaphore'))) {
                        $this->method = $method;
                } else {
-                       throw new Exception('No such method "' . $method . '"');
+                       throw new InvalidArgumentException('No such method "' . $method . '"', 1294586097);
                }
 
                $success = FALSE;
@@ -159,14 +159,14 @@ class t3lib_lock {
                                }
 
                                if (!$isAcquired) {
-                                       throw new Exception('Lock file could not be created');
+                                       throw new RuntimeException('Lock file could not be created', 1294586098);
                                }
 
                                t3lib_div::fixPermissions($this->resource);
                        break;
                        case 'flock':
                                if (($this->filepointer = fopen($this->resource, 'w+')) == FALSE) {
-                                       throw new Exception('Lock file could not be opened');
+                                       throw new RuntimeException('Lock file could not be opened', 1294586099);
                                }
 
                                if (flock($this->filepointer, LOCK_EX | LOCK_NB) == TRUE) { // Lock without blocking
@@ -174,7 +174,7 @@ class t3lib_lock {
                                } elseif (flock($this->filepointer, LOCK_EX) == TRUE) { // Lock with blocking (waiting for similar locks to become released)
                                        $noWait = FALSE;
                                } else {
-                                       throw new Exception('Could not lock file "' . $this->resource . '"');
+                                       throw new RuntimeException('Could not lock file "' . $this->resource . '"', 1294586100);
                                }
                        break;
                        case 'semaphore':
index 1a92073..4ec06cf 100644 (file)
@@ -92,9 +92,11 @@ class t3lib_SpriteManager {
 
                                        // Throw exception if handler class does not implement required interface
                                if (!$this->handler || !($this->handler instanceof t3lib_spritemanager_SpriteIconGenerator)) {
-                                       throw new Exception(
-                                               "class in TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] does not exist,
-                                               or does not implement t3lib_spritemanager_SpriteIconGenerator"
+                                       throw new RuntimeException(
+                                               'Class in $TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] (' .
+                                               $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] .
+                                               ') does not exist or does not implement t3lib_spritemanager_SpriteIconGenerator.',
+                                               1294586333
                                        );
                                }
 
index b572e66..c3a047b 100644 (file)
@@ -732,7 +732,7 @@ class t3lib_treeView {
                        $newID = $row['uid'];
 
                        if ($newID == 0) {
-                               throw new RuntimeException('Endless recursion detected: TYPO3 has detected an error in the database. Please fix it manually (e.g. using phpMyAdmin) and change the UID of ' . $this->table . ':0 to a new value.<br /><br />See <a href="http://bugs.typo3.org/view.php?id=3495" target="_blank">bugs.typo3.org/view.php?id=3495</a> to get more information about a possible cause.');
+                               throw new RuntimeException('Endless recursion detected: TYPO3 has detected an error in the database. Please fix it manually (e.g. using phpMyAdmin) and change the UID of ' . $this->table . ':0 to a new value.<br /><br />See <a href="http://bugs.typo3.org/view.php?id=3495" target="_blank">bugs.typo3.org/view.php?id=3495</a> to get more information about a possible cause.', 1294586383);
                        }
 
                        $this->tree[] = array(); // Reserve space.
index fd6b96b..b054afe 100644 (file)
@@ -713,15 +713,15 @@ class t3lib_TSparser {
 
                                                // some file checks
                                        if (empty($realFileName)) {
-                                               throw new Exception(sprintf('"%s" is not a valid file location.', $fileName));
+                                               throw new UnexpectedValueException(sprintf('"%s" is not a valid file location.', $fileName), 1294586441);
                                        }
 
                                        if (!is_writable($realFileName)) {
-                                               throw new Exception(sprintf('"%s" is not writable.', $fileName));
+                                               throw new RuntimeException(sprintf('"%s" is not writable.', $fileName), 1294586442);
                                        }
 
                                        if (in_array($realFileName, $extractedFileNames)) {
-                                               throw new Exception(sprintf('Recursive/multiple inclusion of file "%s"', $realFileName));
+                                               throw new RuntimeException(sprintf('Recursive/multiple inclusion of file "%s"', $realFileName), 1294586443);
                                        }
                                        $extractedFileNames[] = $realFileName;
 
@@ -729,7 +729,7 @@ class t3lib_TSparser {
                                        $fileContentString = self::extractIncludes($fileContentString, ++$cycle_counter, $extractedFileNames);
 
                                        if (!t3lib_div::writeFile($realFileName, $fileContentString)) {
-                                               throw new Exception(sprintf('Could not write file "%s"', $realFileName));
+                                               throw new RuntimeException(sprintf('Could not write file "%s"', $realFileName), 1294586444);
                                        }
 
                                                // insert reference to the file in the rest content
index e620243..a312166 100644 (file)
@@ -243,7 +243,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                        }
                }
                if ($exitOnError) {
-                       throw new RuntimeException('Access Error: This page is not within your DB-mounts');
+                       throw new RuntimeException('Access Error: This page is not within your DB-mounts', 1294586445);
                }
        }
 
@@ -257,7 +257,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
        function modAccess($conf, $exitOnError) {
                if (!t3lib_BEfunc::isModuleSetInTBE_MODULES($conf['name'])) {
                        if ($exitOnError) {
-                               throw new RuntimeException('Fatal Error: This module "' . $conf['name'] . '" is not enabled in TBE_MODULES');
+                               throw new RuntimeException('Fatal Error: This module "' . $conf['name'] . '" is not enabled in TBE_MODULES', 1294586446);
                        }
                        return FALSE;
                }
@@ -270,7 +270,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                                // ok, go on...
                        } else {
                                if ($exitOnError) {
-                                       throw new RuntimeException('Workspace Error: This module "' . $conf['name'] . '" is not available under the current workspace');
+                                       throw new RuntimeException('Workspace Error: This module "' . $conf['name'] . '" is not available under the current workspace', 1294586447);
                                }
                                return FALSE;
                        }
@@ -286,7 +286,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                        $acs = $this->check('modules', $conf['name']);
                }
                if (!$acs && $exitOnError) {
-                       throw new RuntimeException('Access Error: You don\'t have access to this module.');
+                       throw new RuntimeException('Access Error: You don\'t have access to this module.', 1294586448);
                } else {
                        return $acs;
                }
index 3247392..830b19a 100644 (file)
@@ -147,7 +147,7 @@ class t3lib_extjs_ExtDirectRouter {
                        // theoretically this can never happen, because of an javascript error on
                        // the client side due the missing namespace/endpoint
                if (!isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'][$endpointName])) {
-                       throw new UnexpectedValueException('ExtDirect: Call to undefined endpoint: ' . $endpointName);
+                       throw new UnexpectedValueException('ExtDirect: Call to undefined endpoint: ' . $endpointName, 1294586450);
                }
 
                $endpointObject = t3lib_div::getUserObj(
index 8dbd4a8..1e3512c 100644 (file)
@@ -125,7 +125,7 @@ abstract class t3lib_formprotection_Abstract {
                $formName, $action = '', $formInstanceName = ''
        ) {
                if ($formName == '') {
-                       throw new InvalidArgumentException('$formName must not be empty.');
+                       throw new InvalidArgumentException('$formName must not be empty.', 1294586643);
                }
 
                do {
index c90e122..502db0b 100644 (file)
@@ -130,7 +130,7 @@ class t3lib_mail_Mailer extends Swift_Mailer {
                        case 'mbox':
                                $mboxFile = $mailSettings['transport_mbox_file'];
                                if ($mboxFile == '') {
-                                       throw new t3lib_exception('$TYPO3_CONF_VARS[\'MAIL\'][\'transport_mbox_file\'] needs to be set when transport is set to "mbox"');
+                                       throw new t3lib_exception('$TYPO3_CONF_VARS[\'MAIL\'][\'transport_mbox_file\'] needs to be set when transport is set to "mbox"', 1294586645);
                                }
                                        // Create our transport
                                $this->transport = t3lib_div::makeInstance('t3lib_mail_mboxtransport', $mboxFile);
index 3a79ce2..ea54d75 100644 (file)
@@ -94,7 +94,7 @@ class t3lib_mail_MboxTransport implements Swift_Transport {
                        // Write the mbox file
                $file = @fopen($this->debugFile, 'a');
                if (!$file) {
-                       throw new Exception(
+                       throw new RuntimeException(
                                sprintf('Could not write to file "%s" when sending an email to debug transport', $this->debugFile),
                                1291064151
                        );
index df7bc7f..8f3f1c4 100644 (file)
@@ -251,7 +251,7 @@ class t3lib_tree_Node implements t3lib_tree_ComparableNode, Serializable {
        public function unserialize($serializedString) {
                $arrayRepresentation = unserialize($serializedString);
                if ($arrayRepresentation['serializeClassName'] !== get_class($this)) {
-                       throw new t3lib_exception('Deserialized object type is not identical!');
+                       throw new t3lib_exception('Deserialized object type is not identical!', 1294586646);
                }
                $this->dataFromArray($arrayRepresentation);
        }
index 6a7b607..266f11e 100644 (file)
@@ -87,7 +87,7 @@ class t3lib_tree_NodeCollection extends ArrayObject {
        public function unserialize($serializedString) {
                $arrayRepresentation = unserialize($serializedString);
                if ($arrayRepresentation['serializeClassName'] !== get_class($this)) {
-                       throw new t3lib_exception('Deserialized object type is not identical!');
+                       throw new t3lib_exception('Deserialized object type is not identical!', 1294586647);
                }
                $this->dataFromArray($arrayRepresentation);
        }
index cdb2625..fa524c7 100644 (file)
@@ -291,7 +291,7 @@ class t3lib_tree_Tca_DatabaseTreeDataProvider extends t3lib_tree_Tca_AbstractTca
                if (isset($this->columnConfiguration['foreign_table']) && $this->columnConfiguration['foreign_table'] != $this->getTableName()) {
                        throw new InvalidArgumentException(
                                'TCA Tree configuration is invalid: tree for different node-Tables is not implemented yet',
-                               '1290944650'
+                               1290944650
                        );
                }
 
index 6cb56aa..bb11d15 100644 (file)
@@ -63,7 +63,7 @@ class t3lib_tree_Tca_DataProviderFactory {
                        } else {
                                throw new InvalidArgumentException(
                                        'TCA Tree configuration is invalid: "foreign_table" not set',
-                                       '1288215888'
+                                       1288215888
                                );
                        }
 
@@ -104,13 +104,13 @@ class t3lib_tree_Tca_DataProviderFactory {
                                } else {
                                        throw new InvalidArgumentException(
                                                'TCA Tree configuration is invalid: neither "childrenField" nor "parentField" is set',
-                                               '1288215889'
+                                               1288215889
                                        );
                                }
                        } else {
                                throw new InvalidArgumentException(
                                        'TCA Tree configuration is invalid: "treeConfig" array is missing',
-                                       '1288215890'
+                                       1288215890
                                );
                        }
 
@@ -118,14 +118,14 @@ class t3lib_tree_Tca_DataProviderFactory {
                        // Not implemented yet
                        throw new InvalidArgumentException(
                                'TCA Tree configuration is invalid: tree for "internal_type=file" not implemented yet',
-                               '1288215891'
+                               1288215891
                        );
                } else {
                        throw new InvalidArgumentException(
                                'TCA Tree configuration is invalid: tree for "internal_type=' .
                                $tcaConfiguration['internal_type'] .
                                '" not implemented yet',
-                               '1288215892'
+                               1288215892
                        );
                }
 
index 7daed08..a774b3c 100644 (file)
@@ -46,7 +46,7 @@ if (t3lib_extMgm::isLoaded('recordlist')) {
 } else {
        $title = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:extension.not.installed'), 'list');
        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:link.to.dblist.correctly');
-       throw new RuntimeException($title . ': ' . $message);
+       throw new RuntimeException($title . ': ' . $message, 1294586840);
 }
 
 ?>
index dcbedff..c3e4f42 100644 (file)
@@ -113,7 +113,7 @@ class SC_file_edit {
                if (!$this->target || !$key) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
                        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
-                       throw new RuntimeException($title . ': ' . $message);
+                       throw new RuntimeException($title . ': ' . $message, 1294586841);
                }
                        // Finding the icon
                switch($GLOBALS['FILEMOUNTS'][$key]['type'])    {
index 55dd460..f3c3d53 100644 (file)
@@ -46,6 +46,6 @@ if (t3lib_extMgm::isLoaded('filelist')) {
 } else {
        $title = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:extension.not.installed'), 'list');
        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:link.to.filelist.correctly');
-       throw new RuntimeException($title . ': ' . $message);
+       throw new RuntimeException($title . ': ' . $message, 1294586842);
 }
 ?>
\ No newline at end of file
index b054465..d7ab73b 100644 (file)
@@ -136,7 +136,7 @@ class SC_file_newfolder {
                if (!$this->target || !$key) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
                        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
-                       throw new RuntimeException($title . ': ' . $message);
+                       throw new RuntimeException($title . ': ' . $message, 1294586843);
                }
 
                        // Finding the icon
index a1e61bd..2f55920 100644 (file)
@@ -124,7 +124,7 @@ class SC_file_rename {
                if (!$this->target || !$key) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
                        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
-                       throw new RuntimeException($title . ': ' . $message);
+                       throw new RuntimeException($title . ': ' . $message, 1294586844);
                }
 
                        // Finding the icon
index 293a50f..034e7ca 100644 (file)
@@ -135,7 +135,7 @@ class SC_file_upload {
                if (!$this->target || !$key) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
                        $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
-                       throw new RuntimeException($title . ': ' . $message);
+                       throw new RuntimeException($title . ': ' . $message, 1294586845);
                }
 
                        // Finding the icon
index b1d7e16..3826122 100644 (file)
@@ -366,7 +366,7 @@ class SC_index {
                                if ($this->commandLI=='setCookie') {
                                                // we tried it a second time but still no cookie
                                                // 26/4 2005: This does not work anymore, because the saving of challenge values in $_SESSION means the system will act as if the password was wrong.
-                                       throw new RuntimeException('Login-error: Yeah, that\'s a classic. No cookies, no TYPO3.<br /><br />Please accept cookies from TYPO3 - otherwise you\'ll not be able to use the system.');
+                                       throw new RuntimeException('Login-error: Yeah, that\'s a classic. No cookies, no TYPO3.<br /><br />Please accept cookies from TYPO3 - otherwise you\'ll not be able to use the system.', 1294586846);
                                } else {
                                                // try it once again - that might be needed for auto login
                                        $this->redirectToURL = 'index.php?commandLI=setCookie';
index aa1f048..c0330d5 100644 (file)
@@ -275,7 +275,7 @@ if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) && basename(PATH_thisScript) ==
 // Check Hardcoded lock on BE:
 // **********************
 if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0) {
-       throw new RuntimeException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . intval($TYPO3_CONF_VARS['BE']['adminOnly']) . '".');
+       throw new RuntimeException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . intval($TYPO3_CONF_VARS['BE']['adminOnly']) . '".', 1294586847);
 }
 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) && @is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
        if (TYPO3_PROCEED_IF_NO_USER == 2) {
@@ -285,7 +285,7 @@ if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) && @is_file(PATH_typo3conf . 'L
                if ($fContent)  {
                        header('Location: '.$fContent); // Redirect
                } else {
-                       throw new RuntimeException('TYPO3 Backend locked: Browser backend is locked for maintenance. Remove lock by removing the file "typo3conf/LOCK_BACKEND" or use CLI-scripts.');
+                       throw new RuntimeException('TYPO3 Backend locked: Browser backend is locked for maintenance. Remove lock by removing the file "typo3conf/LOCK_BACKEND" or use CLI-scripts.', 1294586848);
                }
                exit;
        }
@@ -371,9 +371,9 @@ if (!TYPO3_db_host && !TYPO3_db) {
        t3lib_utility_Http::redirect('install/index.php?mode=123&step=1&password=joh316');
 } elseif ($TYPO3_DB->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
        if (!TYPO3_db)  {
-               throw new RuntimeException('Database Error: No database selected', time());
+               throw new RuntimeException('Database Error: No database selected', 1294587021);
        } elseif (!$TYPO3_DB->sql_select_db(TYPO3_db))  {
-               throw new RuntimeException('Database Error: Cannot connect to the current database, "' . TYPO3_db . '"', time());
+               throw new RuntimeException('Database Error: Cannot connect to the current database, "' . TYPO3_db . '"', 1294587022);
        }
 } else {
        throw new RuntimeException('Database Error: The current username, password or host was not accepted when the connection to the database was attempted to be established!', time());
@@ -384,7 +384,7 @@ if (!TYPO3_db_host && !TYPO3_db) {
 // Checks for proper browser
 // *******************************
 if (!$CLIENT['BROWSER'] && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
-       throw new RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', time());
+       throw new RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
 }
 
 
index 5d0088b..51df63b 100644 (file)
@@ -63,7 +63,7 @@ if ($temp_path = $TBE_MODULES['_PATHS'][$temp_M]) {
 }
 
 if ($isDispatched === FALSE) {
-       die('Value "' . htmlspecialchars($temp_M) . '" for "M" was not found as a module');
+       throw new UnexpectedValueException('No module "' . htmlspecialchars($temp_M) . '" could be found.', 1294585070);
 }
 
 ?>
\ No newline at end of file
index ac9b83f..771a7e9 100644 (file)
                                                $message = 'No pages are found on the rootlevel!';
                                                t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
                                                header('HTTP/1.0 503 Service Temporarily Unavailable');
-                                               throw new RuntimeException($message);
+                                               throw new RuntimeException($message, 1294587207);
                                        }
                                }
                        }
                                        $message = 'The requested page does not exist!';
                                        header('HTTP/1.0 404 Page Not Found');
                                        t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                                       throw new RuntimeException($message);
+                                       throw new RuntimeException($message, 1294587208);
                                }
                        }
                }
                                $message = 'The requested page does not exist!';
                                header('HTTP/1.0 404 Page Not Found');
                                t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                               throw new RuntimeException($message);
+                               throw new RuntimeException($message, 1294587209);
                        }
                }
 
                                        $message = 'The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')';
                                        header('HTTP/1.0 503 Service Temporarily Unavailable');
                                        t3lib_div::sysLog(str_replace('<br /><br />','',$message), 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                                       throw new RuntimeException($message);
+                                       throw new RuntimeException($message, 1294587210);
                                }
                        }
                        $this->fePreview = 1;
                                        $message = 'The requested page was not accessible!';
                                        header('HTTP/1.0 503 Service Temporarily Unavailable');
                                        t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                                       throw new RuntimeException($message);
+                                       throw new RuntimeException($message, 1294587211);
                                }
                        } else {
                                $el = reset($this->rootLine);
                                $message = 'Page shortcuts were looping in uids '.implode(',',$pageLog).'...!';
                                header('HTTP/1.0 500 Internal Server Error');
                                t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                               throw new RuntimeException($message);
+                               throw new RuntimeException($message, 1294587212);
                        }
                }
                        // Return resulting page:
 
                        // Create response:
                if (gettype($code)=='boolean' || !strcmp($code,1))      {       // Simply boolean; Just shows TYPO3 error page with reason:
-                       throw new RuntimeException('The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . htmlspecialchars($reason) : ''));
+                       throw new RuntimeException('The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . htmlspecialchars($reason) : ''), 1294587213);
                } elseif (t3lib_div::isFirstPartOfStr($code,'USER_FUNCTION:')) {
                        $funcRef = trim(substr($code,14));
                        $params = array(
                                $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent);
                                echo $fileContent;
                        } else {
-                               throw new RuntimeException('Configuration Error: 404 page "' . $readFile.'" could not be found.');
+                               throw new RuntimeException('Configuration Error: 404 page "' . $readFile.'" could not be found.', 1294587214);
                        }
                } elseif (t3lib_div::isFirstPartOfStr($code,'REDIRECT:')) {
                        t3lib_utility_Http::redirect(substr($code, 9));
                                        $reason = 'Page cannot be found.';
                                }
                                $reason.= LF . LF . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
-                               throw new RuntimeException('Reason: ' . nl2br(htmlspecialchars($reason)));
+                               throw new RuntimeException(nl2br(htmlspecialchars($reason)), 1294587215);
                        }
 
                                // Prepare headers
                                echo $content;  // Output the content
                        }
                } else {
-                       throw new RuntimeException($reason ? 'Reason: '.htmlspecialchars($reason) : 'Page cannot be found.');
+                       throw new RuntimeException($reason ? htmlspecialchars($reason) : 'Page cannot be found.', 1294587216);
                }
                exit();
        }
 
                                                        // Return preview keyword configuration:
                                                return $previewConfig;
-                                       } else die(htmlspecialchars('Request URL did not match "'.t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.$inputCode.'"'));    // This check is to prevent people from setting additional GET vars via realurl or other URL path based ways of passing parameters.
-                               } else die('POST requests are incompatible with keyword preview.');
-                       } else die('ADMCMD command could not be executed! (No keyword configuration found)');
+                                       } else throw new Exception(htmlspecialchars('Request URL did not match "' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'index.php?ADMCMD_prev=' . $inputCode . '"', 1294585190));        // This check is to prevent people from setting additional GET vars via realurl or other URL path based ways of passing parameters.
+                               } else throw new Exception('POST requests are incompatible with keyword preview.', 1294585191);
+                       } else throw new Exception('ADMCMD command could not be executed! (No keyword configuration found)', 1294585192);
                }
        }
 
         * @return      void
         * @see ADMCMD_preview(), index_ts.php
         */
-       function ADMCMD_preview_postInit($previewConfig){
-               if (is_array($previewConfig))   {
-
-                               // Clear cookies:
-                       unset($_COOKIE['be_typo_user']);
-                       $this->ADMCMD_preview_BEUSER_uid = $previewConfig['BEUSER_uid'];
-
-               } else die('Error in preview configuration.');
+       function ADMCMD_preview_postInit(array $previewConfig){
+                       // Clear cookies:
+               unset($_COOKIE['be_typo_user']);
+               $this->ADMCMD_preview_BEUSER_uid = $previewConfig['BEUSER_uid'];
        }
 
 
                                                $message = 'The page is not configured! [type= '.$this->type.']['.$this->sPre.']';
                                                header('HTTP/1.0 503 Service Temporarily Unavailable');
                                                t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                                               throw new RuntimeException($message);
+                                               throw new RuntimeException($message, 1294587217);
                                        }
                                } else {
                                        $this->config['config'] = array();
                                        $message = 'No TypoScript template found!';
                                        header('HTTP/1.0 503 Service Temporarily Unavailable');
                                        t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
-                                       throw new RuntimeException($message);
+                                       throw new RuntimeException($message, 1294587218);
                                }
                        }
                }
                                                                header('Content-Disposition: attachment; filename="'.basename($absoluteFileName) . '"');
                                                                readfile($absoluteFileName);
                                                                exit;
-                                                       } else die('jumpurl Secure: "'.$this->jumpurl.'" was not a valid file!');
-                                               } else die('jumpurl Secure: The requested file was not allowed to be accessed through jumpUrl (path or file not allowed)!');
-                                       } else die('jumpurl Secure: locationData, '.$locationData.', was not accessible.');
-                               } else die('jumpurl Secure: Calculated juHash did not match the submitted juHash.');
+                                                       } else throw new Exception('jumpurl Secure: "' . $this->jumpurl . '" was not a valid file!', 1294585193);
+                                               } else throw new Exception('jumpurl Secure: The requested file was not allowed to be accessed through jumpUrl (path or file not allowed)!', 1294585194);
+                                       } else throw new Exception('jumpurl Secure: locationData, ' . $locationData . ', was not accessible.', 1294585195);
+                               } else throw new Exception('jumpurl Secure: Calculated juHash did not match the submitted juHash.', 1294585196);
                        } else {
                                $TSConf = $this->getPagesTSconfig();
                                if ($TSConf['TSFE.']['jumpUrl_transferSession'])        {
index ecbc8ba..9acc6a3 100644 (file)
@@ -125,7 +125,7 @@ This setting has been deprecated in TYPO 3.8.1 due to security concerns.
 You need to change this value to the URL of your website root, otherwise TYPO3 will not work!
 
 See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.typo3.org/index.php/TYPO3_3.8.1</a> for more information.';
-                               throw new RuntimeException(nl2br($error));
+                               throw new RuntimeException(nl2br($error), 1294587219);
                        } else {
                                $GLOBALS['TSFE']->baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
                        }
index 6b8d04a..b3727d4 100644 (file)
@@ -161,7 +161,9 @@ $TT->pull();
 // *******************************
 // Checking environment
 // *******************************
-if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS']))       die('You cannot set the GLOBALS-array from outside the script.');
+if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS'])) {
+       throw new Exception('You cannot set the GLOBALS-array from outside the script.', 1294585200);
+}
 if (!get_magic_quotes_gpc())   {
        $TT->push('Add slashes to GET/POST arrays','');
        t3lib_div::addSlashesOnArray($_GET);
index 516a5c6..5146946 100644 (file)
@@ -170,7 +170,7 @@ class SC_tslib_showpic {
                // ***********************
                        // If no file-param or parameters are given, we must exit
                if (!$this->file || !isset($parametersArray) || !is_array($parametersArray)) {
-                       throw new UnexpectedValueException('Parameter Error: No file or no parameters given.');
+                       throw new UnexpectedValueException('Parameter Error: No file or no parameters given.', 1299514081);
                }
 
                $this->parametersEncoded = implode($parametersArray);
@@ -184,7 +184,7 @@ class SC_tslib_showpic {
                );
 
                if ($md5_value!=$this->md5) {
-                       throw new UnexpectedValueException('Parameter Error: Wrong parameters sent.');
+                       throw new UnexpectedValueException('Parameter Error: Wrong parameters sent.', 1299514082);
                }
 
                $parameters = unserialize(base64_decode($this->parametersEncoded));
@@ -199,10 +199,10 @@ class SC_tslib_showpic {
 
                $test_file=PATH_site.$this->file;
                if (!t3lib_div::validPathStr($test_file))       {
-                       throw new UnexpectedValueException('Parameter Error: No valid filepath');
+                       throw new UnexpectedValueException('Parameter Error: No valid filepath', 1299514083);
                }
                if (!@is_file($test_file))      {
-                       throw new UnexpectedValueException('The given file was not found');
+                       throw new UnexpectedValueException('The given file was not found', 1299514084);
                }
        }
 
index 5b7a76f..13818f0 100755 (executable)
@@ -308,7 +308,8 @@ class tx_install extends t3lib_install {
                        if (count($missingPhpModules) > 0) {
                                throw new RuntimeException('TYPO3 Installation Error: The following PHP module(s) is/are missing: <em>' .
                                                implode(', ', $missingPhpModules) .
-                                               '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.'
+                                               '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.',
+                                       1294587482
                                );
                        }
                }
@@ -8424,7 +8425,7 @@ $out="
         */
        public function addErrorMessage($messageText) {
                if ($messageText == '') {
-                       throw new InvalidArgumentException('$messageText must not be empty.');
+                       throw new InvalidArgumentException('$messageText must not be empty.', 1294587483);
                }
 
                $this->errorMessages[] = $messageText;
index 1056c9c..8363dd9 100644 (file)
@@ -93,7 +93,7 @@ class tx_install_session {
                $sessionSavePath = $this->getSessionSavePath();
                if (!is_dir($sessionSavePath)) {
                        if (!t3lib_div::mkdir($sessionSavePath)) {
-                               throw new Exception('<p><strong>Could not create session folder in typo3temp/.</strong></p><p>Make sure it is writeable!</p>');
+                               throw new RuntimeException('Could not create session folder in typo3temp/. Make sure it is writeable!', 1294587484);
                        }
                        t3lib_div::writeFile($sessionSavePath.'/.htaccess', 'Order deny, allow'."\n".'Deny from all'."\n");
                        $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
@@ -121,14 +121,14 @@ class tx_install_session {
                        ini_set('session.cookie_httponly', TRUE);
                }
                if (ini_get('session.auto_start')) {
-                       $sessionCreationError = '<p><strong>Error: session.auto-start is enabled</strong></p>';
-                       $sessionCreationError .= '<p>The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:</p>';
+                       $sessionCreationError = 'Error: session.auto-start is enabled.<br />';
+                       $sessionCreationError .= 'The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:<br />';
                        $sessionCreationError .= '<pre>php_value session.auto_start Off</pre>';
-                       throw new Exception($sessionCreationError);
+                       throw new RuntimeException($sessionCreationError, 1294587485);
                } else if (defined('SID')) {
-                       $sessionCreationError = '<p><strong>Error: Session already started by session_start().</strong></p>';
-                       $sessionCreationError .= '<p>Make sure no installed extension is starting a session in its ext_localconf.php or ext_tables.php.</p>';
-                       throw new Exception($sessionCreationError);
+                       $sessionCreationError = 'Session already started by session_start().<br />';
+                       $sessionCreationError .= 'Make sure no installed extension is starting a session in its ext_localconf.php or ext_tables.php.';
+                       throw new RuntimeException($sessionCreationError, 1294587486);
                }
                session_start();
        }
index 244444b..489bfb1 100755 (executable)
@@ -164,7 +164,7 @@ class language {
                        $this->charSet = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'];
 
                        if ($this->charSet != 'utf-8' && !$this->csConvObj->initCharset($this->charSet)) {
-                               throw new RuntimeException('Forced charset not found: The forced character set "'. $this->charSet . '" was not found in t3lib/csconvtbl/');
+                               throw new RuntimeException('Forced charset not found: The forced character set "'. $this->charSet . '" was not found in t3lib/csconvtbl/', 1294587487);
                        }
                }
        }
index 56d83b7..9321750 100644 (file)
@@ -1133,7 +1133,7 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        }
                        $failure = t3lib_div::writeFileToTypo3tempDir($destination, $compressedJavaScript ? $compressedJavaScript : $output);
                        if ($failure)  {
-                               die($failure);
+                               throw new RuntimeException($failure, 1294585668);
                        }
                }
                if ($concatenate && $fileExtension == 'js') {
@@ -1165,12 +1165,12 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                if (!file_exists($destination)) {
                                        $failure = t3lib_div::writeFileToTypo3tempDir($destination, $contents);
                                        if ($failure)  {
-                                               die($failure);
+                                               throw new RuntimeException($failure, 1294585669);
                                        }
                                } else {
                                        $success = file_put_contents($destination, $contents, FILE_APPEND);
                                        if (!$success)  {
-                                               die('Could not append script' + $fileName);
+                                               throw new RuntimeException('Could not append script: ' . $fileName, 1294585670);
                                        }
                                }
                        }
index a7b3a14..9040245 100644 (file)
@@ -229,7 +229,7 @@ class tx_rtehtmlarea_pi1 {
                        if (!xml_set_default_handler($parser, 'defaultHandler')) echo('Bad xml handler setting');
                        if (!xml_parse($parser,'<?xml version="1.0" encoding="' . $this->parserCharset . '"?><spellchecker> ' . preg_replace('/&nbsp;/'.(($this->parserCharset == 'utf-8')?'u':''), ' ', $content) . ' </spellchecker>')) echo('Bad parsing');
                        if (xml_get_error_code($parser)) {
-                               die('Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser)));
+                               throw new UnexpectedException('Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)), 1294585788);
                        }
                        xml_parser_free($parser);
                        if ($this->pspell_is_available && !$this->forceCommandMode) {
index 04adb49..938c005 100755 (executable)
@@ -1470,7 +1470,7 @@ class tx_scheduler_Module extends t3lib_SCbase {
                        }
                                // If the timestamp is still false, throw an exception
                        if ($timestamp === false) {
-                               throw new Exception;
+                               throw new InvalidArgumentException('"' . $string . '" seems not to be a correct date.', 1294587694);
                        }
                }
                return $timestamp;
index 106734c..7a84bbb 100644 (file)
@@ -108,7 +108,7 @@ class tx_simulatestatic {
                                        header(t3lib_utility_Http::HTTP_STATUS_503);
                                        t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
                                        $message = 'Error: PATH_INFO not configured: ' . $message . '<br /><br /><a href="' . htmlspecialchars($redirectUrl) . '">Click here to get to the right page.</a>';
-                                       throw new RuntimeException($message);
+                                       throw new RuntimeException($message, 1294587706);
                                }
                        } else {
                                t3lib_utility_Http::redirect($redirectUrl);
index 7b6465d..5f004ec 100644 (file)
@@ -317,7 +317,7 @@ class SC_wizard_forms {
                        // First, check the references by selecting the record:
                $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
                if (!is_array($row)) {
-                       throw new RuntimeException('Wizard Error: No reference to record');
+                       throw new RuntimeException('Wizard Error: No reference to record', 1294587124);
                }
 
                        // This will get the content of the form configuration code field to us - possibly cleaned up, saved to database etc. if the form has been submitted in the meantime.
index f1c12ad..fbc9366 100644 (file)
@@ -236,7 +236,7 @@ class SC_wizard_table {
                        // First, check the references by selecting the record:
                $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
                if (!is_array($row)) {
-                       throw new RuntimeException('Wizard Error: No reference to record');
+                       throw new RuntimeException('Wizard Error: No reference to record', 1294587125);
                }
 
                        // This will get the content of the form configuration code field to us - possibly cleaned up, saved to database etc. if the form has been submitted in the meantime.