Project

General

Profile

Bug #22410 » 14050_cleaning_t3lib_error_directory.patch

Administrator Admin, 2010-11-24 21:21

View differences:

t3lib/error/class.t3lib_error_productionexceptionhandler.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* A quite exception handler which catches but ignores any exception.
*
......
if (!headers_sent()) {
header("HTTP/1.1 500 Internal Server Error");
}
$this->writeLogEntries($exception,self::CONTEXT_WEB);
$this->writeLogEntries($exception, self::CONTEXT_WEB);
// we use a nice-looking title for our visitors instead of the exception's class name
$messageObj = t3lib_div::makeInstance('t3lib_message_ErrorPageMessage', $exception->getMessage(), 'Oops, an error occured!');
$messageObj->output();
......
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php']);
}
t3lib/error/class.t3lib_error_errorhandler.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Global error handler for TYPO3
*
......
/**
* Registers this class as default error handler
*
* @param integer The integer representing the E_* error level which should be
* @param integer The integer representing the E_* error level which should be
* handled by the registered error handler.
* handled by the registered error handler.
* @return void
*/
public function __construct($errorHandlerErrors) {
......
}
/**
* Defines which error levels should result in an exception thrown.
*
* @param integer The integer representing the E_* error level to handle as exceptions
* @param integer The integer representing the E_* error level to handle as exceptions
* @return void
*/
public function setExceptionalErrors($exceptionalErrors) {
$this->exceptionalErrors = (int)$exceptionalErrors;
$this->exceptionalErrors = (int) $exceptionalErrors;
}
......
* If TYPO3_MODE is 'BE' the error message is also added to the flashMessageQueue, in FE the error message
* is displayed in the admin panel (as TsLog message)
*
* @param integer The error level - one of the E_* constants
* @param integer The error level - one of the E_* constants
* @param string The error message
* @param string The error message
* @param string Name of the file the error occurred in
* @param string Name of the file the error occurred in
* @param integer Line number where the error occurred
* @param integer Line number where the error occurred
* @return void
* @throws t3lib_error_Exception with the data passed to this method if the error is registered as exceptionalError
*/
public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine) {
// don't do anything if error_reporting is disabled by an @ sign
if (error_reporting()==0) { return TRUE; }
if (error_reporting() == 0) {
return TRUE;
}
$errorLevels = array (
$errorLevels = array(
E_WARNING => 'Warning',
E_WARNING => 'Warning',
E_NOTICE => 'Notice',
E_NOTICE => 'Notice',
E_USER_ERROR => 'User Error',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
);
$message = 'PHP ' .$errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
$message = 'PHP ' . $errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
if ($errorLevel & $this->exceptionalErrors) {
if (!class_exists('t3lib_error_Exception', FALSE)) {
......
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
$severity = 2;
break;
break;
case E_USER_WARNING:
case E_WARNING:
$severity = 1;
break;
break;
default:
$severity = 0;
break;
break;
}
$logTitle = 'Core: Error handler (' . TYPO3_MODE . ')';
......
// Add error message to the flashmessageQueue
if (defined('TYPO3_ERRORHANDLER_MODE') && TYPO3_ERRORHANDLER_MODE == 'debug') {
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$message,
'PHP ' . $errorLevels[$errorLevel],
$severity
't3lib_FlashMessage',
$message,
'PHP ' . $errorLevels[$errorLevel],
$severity
);
t3lib_FlashMessageQueue::addMessage($flashMessage);
}
......
$userId = 0;
$workspace = 0;
if (is_object($GLOBALS['BE_USER'])) {
if (isset($GLOBALS['BE_USER']->user['uid'])) {
if (isset($GLOBALS['BE_USER']->user['uid'])) {
$userId = $GLOBALS['BE_USER']->user['uid'];
}
if (isset($GLOBALS['BE_USER']->workspace)) {
if (isset($GLOBALS['BE_USER']->workspace)) {
$workspace = $GLOBALS['BE_USER']->workspace;
}
}
$fields_values = Array (
$fields_values = Array(
'userid' => $userId,
'type' => 5,
'action' => 0,
......
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_errorhandler.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_errorhandler.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_errorhandler.php']);
}
t3lib/error/interface.t3lib_error_errorhandlerinterface.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Error handler interface for TYPO3
*
......
/**
* Registers this class as default error handler
*
* @param integer The integer representing the E_* error level which should be
* @param integer The integer representing the E_* error level which should be
* handled by the registered error handler.
* handled by the registered error handler.
* @return void
*/
public function __construct($errorHandlerErrors);
......
/**
* Defines which error levels should result in an exception thrown.
*
* @param integer The integer representing the E_* error level to handle as exceptions
* @param integer The integer representing the E_* error level to handle as exceptions
* @return void
*/
public function setExceptionalErrors($exceptionalErrors);
......
* If TYPO3_MODE is 'BE' the error message is also added to the flashMessageQueue, in FE the error message
* is displayed in the admin panel (as TsLog message)
*
* @param integer The error level - one of the E_* constants
* @param integer The error level - one of the E_* constants
* @param string The error message
* @param string The error message
* @param string Name of the file the error occurred in
* @param string Name of the file the error occurred in
* @param integer Line number where the error occurred
* @param integer Line number where the error occurred
* @return void
* @throws t3lib_error_Exception with the data passed to this method if the error is registered as exceptionalError
*/
t3lib/error/class.t3lib_error_abstractexceptionhandler.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* An abstract exception handler
*
......
* Writes exception to different logs
*
* @param Exception $exception The exception
* @param string the context where the exception was thrown, WEB or CLI
* @param string the context where the exception was thrown, WEB or CLI
* @return void
* @see t3lib_div::sysLog(), t3lib_div::devLog()
*/
......
$exceptionCodeNumber = ($exception->getCode() > 0) ? '#' . $exception->getCode() . ': ' : '';
$logTitle = 'Core: Exception handler (' . $context . ')';
$logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' .
get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
$backtrace = $exception->getTrace();
$backtrace = $exception->getTrace();
// write error message to the configured syslogs
t3lib_div::sysLog($logMessage, $logTitle, 4);
......
// write error message to devlog
// see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
if (TYPO3_EXCEPTION_DLOG) {
t3lib_div::devLog($logMessage, $logTitle, 3, array(
t3lib_div::devLog(
$logMessage,
$logTitle,
3,
array(
'TYPO3_MODE' => TYPO3_MODE,
'backtrace' => $backtrace
'TYPO3_MODE' => TYPO3_MODE,
'backtrace' => $backtrace
));
)
);
}
// write error message to sys_log table
......
$userId = 0;
$workspace = 0;
if (is_object($GLOBALS['BE_USER'])) {
if (isset($GLOBALS['BE_USER']->user['uid'])) {
if (isset($GLOBALS['BE_USER']->user['uid'])) {
$userId = $GLOBALS['BE_USER']->user['uid'];
}
if (isset($GLOBALS['BE_USER']->workspace)) {
if (isset($GLOBALS['BE_USER']->workspace)) {
$workspace = $GLOBALS['BE_USER']->workspace;
}
}
$fields_values = Array (
$fields_values = Array(
'userid' => $userId,
'type' => 5,
'action' => 0,
......
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_abstractexceptionhandler.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_abstractexceptionhandler.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_abstractexceptionhandler.php']);
}
t3lib/error/class.t3lib_error_debugexceptionhandler.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* A basic but solid exception handler which catches everything which
* falls through the other exception handlers and provides useful debugging
......
* either remove this line or let the link point to site that offers error information for TYPO3
*/
// $moreInformationLink = ($exceptionCodeNumber != '') ? '(<a href="http://typo3.org/go/exception/' . $exception->getCode() . '">More information</a>)' : '';
// $moreInformationLink = ($exceptionCodeNumber != '') ? '(<a href="http://typo3.org/go/exception/' . $exception->getCode() . '">More information</a>)' : '';
$backtraceCode = $this->getBacktraceCode($exception->getTrace());
$this->writeLogEntries($exception, self::CONTEXT_WEB);
......
">
<div style="width: 100%; background-color: #515151; color: white; padding: 2px; margin: 0 0 6px 0;">Uncaught TYPO3 Exception</div>
<div style="width: 100%; padding: 2px; margin: 0 0 6px 0;">
<strong style="color: #BE0027;">' . $exceptionCodeNumber . $exception->getMessage() . '</strong> ' ./* $moreInformationLink .*/ '<br />
<strong style="color: #BE0027;">' . $exceptionCodeNumber . $exception->getMessage() . '</strong> ' . /* $moreInformationLink .*/
'<br />
<br />
<span class="ExceptionProperty">' . get_class($exception) . '</span> thrown in file<br />
<span class="ExceptionProperty">' . $filePathAndName . '</span> in line
......
$preparedArgument = str_replace(LF, '<span style="color:white;">&crarr;</span>', $preparedArgument);
$arguments .= '"<span style="color:#FF8700;" title="' . htmlspecialchars($argument) . '">' . $preparedArgument . '</span>"';
} elseif (is_numeric($argument)) {
$arguments .= '<span style="color:#FF8700;">' . (string)$argument . '</span>';
$arguments .= '<span style="color:#FF8700;">' . (string) $argument . '</span>';
} else {
$arguments .= '<span style="color:#FF8700;"><em>' . gettype($argument) . '</em></span>';
}
......
if ($endLine > $startLine) {
$codeSnippet = '<br /><span style="font-size:10px;">' . $filePathAndName . ':</span><br /><pre>';
for ($line = $startLine; $line < $endLine; $line++) {
$codeLine = str_replace(TAB, ' ', $phpFile[$line-1]);
$codeLine = str_replace(TAB, ' ', $phpFile[$line - 1]);
if ($line === $lineNumber) {
$codeSnippet .= '</pre><pre style="background-color: #F1F1F1; color: black;">';
......
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_debugexceptionhandler.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_debugexceptionhandler.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_debugexceptionhandler.php']);
}
t3lib/error/interface.t3lib_error_exceptionhandlerinterface.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contract for an exception handler
*
t3lib/error/class.t3lib_error_exception.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2009-2010 Ingo Renner <ingo@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* An exception which represents a PHP error.
*
......
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_exception.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_exception.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_exception.php']);
}
(81-81/93)