Browse Source

fatal errors handling

tags/v1.6.1
Paweł Bukowski 7 years ago
parent
commit
2fdc065550
5 changed files with 9 additions and 21 deletions
  1. +1
    -0
      cron.php
  2. +0
    -5
      include.php
  3. +8
    -12
      include/error.php
  4. +0
    -2
      index.php
  5. +0
    -2
      process.php

+ 1
- 0
cron.php View File

@@ -86,3 +86,4 @@ foreach($cron_last as $func_md5=>$last) {
break;
}
@unlink($lock);


+ 0
- 5
include.php View File

@@ -18,8 +18,6 @@ require_once('include/config.php');
require_once('include/maintenance_mode.php');
require_once('include/epesi.php');
require_once('include/error.php');
//if(JS_OUTPUT)
ob_start(array('ErrorHandler','handle_fatal'));
require_once('include/magicquotes.php');
require_once('include/database.php');
require_once('include/session.php');
@@ -32,6 +30,3 @@ require_once('include/module_common.php');
require_once('include/module.php');
require_once('include/module_manager.php');
require_once('include/patches.php');
//if(JS_OUTPUT)
ob_end_clean();
?>

+ 8
- 12
include/error.php View File

@@ -34,16 +34,6 @@ class ErrorHandler {
return $buffer;
}
public static function handle_fatal($buffer) {
if (preg_match("/(error<\/b>:)(.+)(<br)/", $buffer, $regs) || preg_match("/(error:)(.+)(\n)/", $buffer, $regs) ) {
$err = preg_replace("/<.*?>/","",$regs[2]);
$err .= self::debug_backtrace();
error_log($err);
return self::notify_client('Fatal: '.$err);
}
return $buffer;
}

public static function handle_error($type, $message,$errfile,$errline,$errcontext) {
if (($type & error_reporting()) > 0) {
$backtrace = self::debug_backtrace();
@@ -234,6 +224,13 @@ function handle_epesi_exception(Exception $exception)
}
}

function check_for_fatal()
{
$error = error_get_last();
if ( $error["type"] == E_ERROR )
ErrorHandler::handle_error( $error["type"], $error["message"], $error["file"], $error["line"], '' );
}

if(REPORT_ALL_ERRORS) {
if (version_compare(phpversion(), '5.4.0')==-1)
$error_reporting_level = E_ALL; //all without notices
@@ -244,8 +241,7 @@ else
$error_reporting_level = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR;

error_reporting($error_reporting_level);
register_shutdown_function( "check_for_fatal" );
set_error_handler('handle_epesi_error', $error_reporting_level);
set_exception_handler('handle_epesi_exception');
unset($error_reporting_level);

?>

+ 0
- 2
index.php View File

@@ -30,7 +30,6 @@ if(!is_writable(DATA_DIR))
require_once('include/config.php');
require_once('include/maintenance_mode.php');
require_once('include/error.php');
ob_start(array('ErrorHandler','handle_fatal'));
require_once('include/database.php');
require_once('include/variables.php');
if(epesi_requires_update()) {
@@ -75,7 +74,6 @@ Please choose <?php print(EPESI);?> version:<ul>
</body>
</html>
<?php
ob_end_flush();
exit();
}
} elseif(detect_mobile_device()) {


+ 0
- 2
process.php View File

@@ -32,9 +32,7 @@ if(!isset($_SESSION['num_of_clients'])) {
//session_commit();
//DBSession::destroy(session_id());
} else {
ob_start(array('ErrorHandler','handle_fatal'));
Epesi::process($_POST['url'],isset($_POST['history'])?$_POST['history']:false);
ob_end_flush();
}
$content = ob_get_contents();
ob_end_clean();


Loading…
Cancel
Save