2010-04-13 Steffen Kamper <info@sk-typo3.de>
+ * Fixed bug #14061: Do not die, be the exception!
* Added Feature #13799: ExtJS driven fading in/out Flashmessages
* Corrected spelling errors in felogin manual
* Added Feature #12229: Add stdWrap date/strftime with GMT format property
/**
* Truncates a table.
- *
+ *
* @param string Database tablename
* @return mixed Result from handler
*/
return $query;
}
} else {
- die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for UPDATE ' .
- 'query was not a string in $this->UPDATEquery() !');
+ throw new InvalidArgumentException(
+ 'TYPO3 Fatal Error: "Where" clause argument for UPDATE query was not a string in $this->UPDATEquery() !',
+ 1270853880
+ );
}
}
}
return $query;
} else {
- die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for DELETE ' .
- 'query was not a string in $this->DELETEquery() !');
+ throw new InvalidArgumentException(
+ 'TYPO3 Fatal Error: "Where" clause argument for DELETE query was not a string in $this->DELETEquery() !',
+ 1270853881
+ );
}
}
/**
* Creates a SELECT SQL-statement to be used as subquery within another query.
* BEWARE: This method should not be overriden within DBAL to prevent quoting from happening.
- *
+ *
* @param string $select_fields: List of fields to select from the table.
* @param string $from_table: Table from which to select.
* @param string $where_clause: Conditional WHERE statement
/**
* Creates a TRUNCATE TABLE SQL-statement
- *
+ *
* @param string See exec_TRUNCATEquery()
* @return string Full SQL query for TRUNCATE TABLE
*/
function connectDB() {
if ($this->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
if (!TYPO3_db) {
- die('No database selected');
- exit;
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: No database selected!',
+ 1270853882
+ );
} elseif (!$this->sql_select_db(TYPO3_db)) {
- die('Cannot connect to the current database, "' . TYPO3_db . '"');
- exit;
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: Cannot connect to the current database, "' . TYPO3_db . '"!',
+ 1270853883
+ );
}
} else {
- die('The current username, password or host was not accepted when the ' .
- 'connection to the database was attempted to be established!');
- exit;
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: The current username, password or host was not accepted when the connection to the database was attempted to be established!',
+ 1270853884
+ );
}
}
* @return string Returns the list without any duplicates of values, space around values are trimmed
*/
public static function uniqueList($in_list, $secondParameter=NULL) {
- if (is_array($in_list)) die('t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!');
- if (isset($secondParameter)) die('t3lib_div::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one.');
+ if (is_array($in_list)) {
+ throw new InvalidArgumentException(
+ 'TYPO3 Fatal Error: t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!',
+ 1270853885
+ );
+ }
+ if (isset($secondParameter)) {
+ throw new InvalidArgumentException(
+ 'TYPO3 Fatal Error: t3lib_div::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one!',
+ 1270853886
+ );
+ }
return implode(',',array_unique(self::trimExplode(',',$in_list,1)));
}
include($fileRef);
if (!is_array($LOCAL_LANG)) {
$fileName = substr($fileRef, strlen(PATH_site));
- die('\'' . $fileName . '\' is no TYPO3 language file)!');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: "' . $fileName . '" is no TYPO3 language file!',
+ 1270853900
+ );
}
// converting the default language (English)
// Cache the content now:
$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
- if ($res) die('ERROR: '.$res);
+ if ($res) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: "' . $res,
+ 1270853901
+ );
+ }
} else {
// Get content from cache:
$serContent = unserialize(self::getUrl($cacheFileName));
$xmlContent = self::xml2array($xmlString);
if (!is_array($xmlContent)) {
$fileName = substr($fileRef, strlen(PATH_site));
- die('The file "' . $fileName . '" is no TYPO3 language file!');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: The file "' . $fileName . '" is no TYPO3 language file!',
+ 1270853902
+ );
}
// Set default LOCAL_LANG array content:
// Cache the content now:
$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
- if ($res) die('ERROR: '.$res);
+ if ($res) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $res,
+ 1270853903
+ );
+ }
} else {
// Get content from cache:
$serContent = unserialize(self::getUrl($cacheFileName));
$local_xmlContent = self::xml2array($local_xmlString);
if (!is_array($local_xmlContent)) {
$fileName = substr($localized_file, strlen(PATH_site));
- die('The file "' . $fileName . '" is no TYPO3 language file!');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: The file "' . $fileName . '" is no TYPO3 language file!',
+ 1270853904
+ );
}
$LOCAL_LANG[$langKey] = is_array($local_xmlContent['data'][$langKey]) ? $local_xmlContent['data'][$langKey] : array();
$serContent = array('extlang'=>$langKey, 'origFile'=>$hashSource, 'EXT_DATA'=>$LOCAL_LANG[$langKey]);
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
if ($res) {
- die('ERROR: '.$res);
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $res,
+ 1270853905
+ );
}
} else {
// Get content from cache:
*/
public static function isLoaded($key, $exitOnError = 0) {
global $TYPO3_LOADED_EXT;
- if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) die('Fatal Error: Extension "'.$key.'" was not loaded.');
+ if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) {
+ throw new BadFunctionCallException(
+ 'TYPO3 Fatal Error: Extension "' . $key . '" was not loaded!',
+ 1270853910
+ );
+ }
return isset($TYPO3_LOADED_EXT[$key]);
}
public static function extPath($key, $script = '') {
global $TYPO3_LOADED_EXT;
if (!isset($TYPO3_LOADED_EXT[$key])) {
- #debug(array(debug_backtrace()));
- die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');
+ throw new BadFunctionCallException(
+ 'TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded!',
+ 1270853878
+ );
}
return PATH_site.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$script;
}
public static function extRelPath($key) {
global $TYPO3_LOADED_EXT;
if (!isset($TYPO3_LOADED_EXT[$key])) {
- die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extRelPath)');
+ throw new BadFunctionCallException(
+ 'TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded!',
+ 1270853879
+ );
}
return $TYPO3_LOADED_EXT[$key]['typo3RelPath'];
}
// Path of this script:
$this->thisPath = dirname($conf['path']);
if (!@is_dir($this->thisPath)) {
- die('Error: '.$this->thisPath.' was not a directory as expected...');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: Extension "' . $this->thisPath . ' was not a directory as expected...',
+ 1270853912
+ );
}
// Local lang:
$writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'].$tmpExt;
// Checking write state of localconf.php:
- if (!$this->allowUpdateLocalConf) {
- die('->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.');
+ if (!$this->allowUpdateLocalConf) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.',
+ 1270853915
+ );
}
if (!@is_writable($writeToLocalconf_dat['file'])) {
- die($writeToLocalconf_dat['file'].' is not writable!');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $writeToLocalconf_dat['file'] . ' is not writable!',
+ 1270853916
+ );
}
// Splitting localconf.php file into lines:
}
$total[$table]['fields'][$fN] = $sqlParser->compileFieldCfg($fInfo);
- if ($sqlParser->parse_error) die($sqlParser->parse_error);
+ if ($sqlParser->parse_error) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $sqlParser->parse_error,
+ 1270853961
+ );
+ }
}
}
}
}
$this->accumulateForNotifEmail = array(); // Reset notification array
-
-# die("REMOVE ME");
}
$perms = intval($perms);
}
- if (!$perms) {die('Internal ERROR: no permissions to check for non-admin user.');}
+ if (!$perms) {
+ throw new RuntimeException(
+ 'Internal ERROR: no permissions to check for non-admin user',
+ 1270853920
+ );
+ }
// For all tables: Check if record exists:
if (is_array($TCA[$table]) && $id>0 && ($this->isRecordInWebMount($table,$id) || $this->admin)) {
if (!preg_match('/[^[:alnum:]_]/',$tableName) && substr($tableName,-5)=='cache') {
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery($tableName);
} else {
- die('Fatal Error: Trying to flush table "'.$tableName.'" with "Clear All Cache"');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: Trying to flush table "' . $tableName . '" with "Clear All Cache"',
+ 1270853922
+ );
}
}
}
if ($this->formfield_status && $loginData['uident'] && $loginData['uname']) {
$httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
if (!$this->getMethodEnabled && ($httpHost!=$authInfo['refInfo']['host'] && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'])) {
- die('Error: This host address ("'.$httpHost.'") and the referer host ("'.$authInfo['refInfo']['host'].'") mismatches!<br />
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: Error: This host address ("' . $httpHost . '") and the referer host ("' . $authInfo['refInfo']['host'] . '") mismatches!<br />
It\'s possible that the environment variable HTTP_REFERER is not passed to the script because of a proxy.<br />
- The site administrator can disable this check in the "All Configuration" section of the Install Tool (flag: TYPO3_CONF_VARS[SYS][doNotCheckReferer]).');
+ The site administrator can disable this check in the "All Configuration" section of the Install Tool (flag: TYPO3_CONF_VARS[SYS][doNotCheckReferer]).',
+ 1270853930
+ );
}
// delete old user session if any
// Refuse login for _CLI users (used by commandline scripts)
if ((strtoupper(substr($loginData['uname'],0,5))=='_CLI_') && (!defined('TYPO3_cliMode') || !TYPO3_cliMode)) { // although TYPO3_cliMode should never be set when using active login...
- die('Error: You have tried to login using a CLI user. Access prohibited!');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: You have tried to login using a CLI user. Access prohibited!',
+ 1270853931
+ );
}
}
* if the client is flash (e.g. from a flash application inside TYPO3 that does a server request)
* then don't evaluate with the hashLockClause, as the client/browser is included in this hash
* and thus, the flash request would be rejected
- *
+ *
* @return DB result object or false on error
* @access private
*/
protected function fetchUserSessionFromDB() {
-
+
if ($GLOBALS['CLIENT']['BROWSER'] == 'flash') {
// if on the flash client, the veri code is valid, then the user session is fetched
// from the DB without the hashLock clause
public function veriCode() {
return substr(md5($this->id . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, 10);
}
-
+
/**
* This returns the where-clause needed to lock a user to a hash integer
*
$typo_db_extTableDef_script = ''; // The filename of an additional script in typo3conf/-folder which is included after tables.php. Code in this script should modify the tables.php-configuration only, and this provides a good way to extend the standard-distributed tables.php file.
// Include localconf.php. Use this file to configure TYPO3 for your needs and database
-if (!@is_file(PATH_typo3conf.'localconf.php')) die('localconf.php is not found!');
+if (!@is_file(PATH_typo3conf . 'localconf.php')) {
+ throw new Exception('localconf.php is not found!');
+}
require(PATH_typo3conf.'localconf.php');
// Defining the database setup as constants
$this->size = $size;
$this->mtime = $mtime;
} else {
- die('Error: Image does not exist and/or MD5 checksum did not match.');
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: Image does not exist and/or MD5 checksum did not match.',
+ 1270853950
+ );
}
}
function errorGif($l1,$l2,$l3) {
global $TYPO3_CONF_VARS;
- if (!$TYPO3_CONF_VARS['GFX']['gdlib']) die($l1.' '.$l2.' '.$l3);
+ if (!$TYPO3_CONF_VARS['GFX']['gdlib']) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: No gdlib. ' . $l1 . ' ' . $l2 . ' ' . $l3,
+ 1270853952
+ );
+ }
// Creates the basis for the error image
if ($TYPO3_CONF_VARS['GFX']['gdlib_png']) {
function fontGif($font) {
global $TYPO3_CONF_VARS;
- if (!$TYPO3_CONF_VARS['GFX']['gdlib']) die('');
+ if (!$TYPO3_CONF_VARS['GFX']['gdlib']) {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: No gdlib.',
+ 1270853953
+ );
+ }
// Create image and set background color to white.
$im = imageCreate(250,76);
Header('Content-Disposition: attachment; filename='.basename($dlFile));
echo t3lib_div::getUrl($dlFile);
exit;
- } else die($GLOBALS['LANG']->getLL('ext_details_error_downloading'));
+ } else {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('ext_details_error_downloading'),
+ 1270853980
+ );
+ }
} elseif ($this->CMD['editFile'] && !in_array($extKey,$this->requiredExt)) {
$content = '<table border="0" cellpadding="2" cellspacing="2">'.implode('',$lines).'</table>';
return $content;
}
- } else die($GLOBALS['LANG']->getLL('extBackup_unexpected_error'));
+ } else {
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('extBackup_unexpected_error'),
+ 1270853981
+ );
+ }
}
/**
$finalDir = PATH_site.$crDirStart;
}
} else {
- die(sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'),
- PATH_site . $crDir
- )
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'), PATH_site . $crDir),
+ 1270853982
);
}
}
$header.LF.LF.LF.
$insertStatements.LF.LF.LF;
} else {
- die($GLOBALS['LANG']->getLL('dumpStaticTables_table_not_found'));
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('dumpStaticTables_table_not_found'),
+ 1270853983
+ );
}
}
return $out;
// Check the zlib
if (!extension_loaded('zlib')) {
- die("The extension 'zlib' couldn't be found.\n".
- "Please make sure your version of PHP was built ".
- "with 'zlib' support.\n");
+ throw new RuntimeException(
+ 'TYPO3 Fatal Error: ' . "The extension 'zlib' couldn't be found.\n" .
+ "Please make sure your version of PHP was built " .
+ "with 'zlib' support.\n",
+ 1270853984
+ );
}
// Set the attributes