From 8cd18fe1907429a3517aaa7e0346b79ed927ca08 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 26 Jul 2018 14:54:45 +0000 Subject: [PATCH] Setup : log in log/setup.log on PHP error (register_shutdown_function callback) SVN:trunk[5987] --- setup/ajax.dataloader.php | 40 ++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/setup/ajax.dataloader.php b/setup/ajax.dataloader.php index e39e6ff03..cfb2266fc 100644 --- a/setup/ajax.dataloader.php +++ b/setup/ajax.dataloader.php @@ -1,5 +1,5 @@ '.$sLogMessage.''; } function FatalErrorCatcher($sOutput) -{ - if ( preg_match('|.*|s', $sOutput, $aMatches) ) +{ + if (preg_match('|<'.PHP_FATAL_ERROR_TAG.'>.*|s', $sOutput, $aMatches)) { header("HTTP/1.0 500 Internal server error."); $errors = ''; @@ -97,9 +121,11 @@ function FatalErrorCatcher($sOutput) //Define some bogus, invalid HTML tags that no sane //person would ever put in an actual document and tell //PHP to delimit fatal error warnings with them. -ini_set('error_prepend_string', ''); -ini_set('error_append_string', ''); +ini_set('error_prepend_string', '<'.PHP_FATAL_ERROR_TAG.'>'); +ini_set('error_append_string', ''); +// callback on errors to log +register_shutdown_function('ShutdownCallback'); // Starts the capture of the ouput, and sets a filter to capture the fatal errors. ob_start('FatalErrorCatcher'); // Start capturing the output, and pass it through the fatal error catcher @@ -140,6 +166,7 @@ try $oDummyController = new WizardController(''); if (is_subclass_of($sClass, 'WizardStep')) { + /** @var WizardStep $oStep */ $oStep = new $sClass($oDummyController, $sState); $sConfigFile = utils::GetConfigFilePath(); if (file_exists($sConfigFile) && !is_writable($sConfigFile) && $oStep->RequiresWritableConfig()) @@ -179,4 +206,3 @@ if (function_exists('memory_get_peak_usage')) SetupPage::log_info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage()); } } -?>