Merge branch 'ent-12087-guardia-16249-error-500-en-reportes' into 'develop'

Ent 12087 guardia 16249 error 500 en reportes

See merge request artica/pandorafms!6526
This commit is contained in:
Matias Didier 2023-10-06 11:25:48 +00:00
commit 3f74126495
1 changed files with 25 additions and 0 deletions

View File

@ -149,6 +149,26 @@ function reporting_get_name($id_report)
} }
/**
* Frees memory in case of fatal error.
*
* @param mixed $memory Object that reserves memory.
*
* @return void
*/
function shutdown($memory)
{
// Unsetting $memory does not free up memory.
// I also tried unsetting a global variable which did not free up the memory.
unset($memory->reserve);
$error = error_get_last();
if (isset($error['type']) === true && $error['type'] === 1) {
echo __('You have no memory for this operation, increase the memory limit.');
}
}
function reporting_make_reporting_data( function reporting_make_reporting_data(
$report, $report,
$id_report, $id_report,
@ -170,6 +190,11 @@ function reporting_make_reporting_data(
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
$memory = new stdClass();
// Reserve 3 mega bytes.
$memory->reserve = str_repeat('*', (1024 * 1024));
register_shutdown_function('shutdown', $memory);
$return = []; $return = [];
if (!empty($report)) { if (!empty($report)) {
$contents = io_safe_output($report['contents']); $contents = io_safe_output($report['contents']);