From 956f6403b891a021db1bb2d300c1b6bedc7b82d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Wed, 25 Jul 2018 08:02:28 +0000 Subject: [PATCH] Display error message for end users instead of blank screen SVN:trunk[5980] --- application/startup.inc.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/application/startup.inc.php b/application/startup.inc.php index 3516200fa..55654924d 100644 --- a/application/startup.inc.php +++ b/application/startup.inc.php @@ -24,6 +24,26 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ +// This storage is freed on error (case of allowed memory exhausted) +$sReservedMemory = str_repeat('*', 1024 * 1024); +register_shutdown_function(function() +{ + global $sReservedMemory; + $sReservedMemory = null; + if (!is_null($err = error_get_last()) && ($err['type'] == E_ERROR)) + { + if (strpos($err['message'], 'Allowed memory size of') !== false) + { + $sLimit = ini_get('memory_limit'); + echo "

iTop: Allowed memory size of $sLimit exhausted, contact your administrator to increase memory_limit in php.ini

\n"; + } + else + { + echo "

iTop: An error occurred, check server error log for more information.

\n"; + } + } +}); + require_once(APPROOT.'/core/cmdbobject.class.inc.php'); require_once(APPROOT.'/application/utils.inc.php'); require_once(APPROOT.'/core/contexttag.class.inc.php');