From a16f6c24e5ed5ca2b07230c8cd27af5de19d60ba Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Fri, 22 Mar 2024 15:27:15 +0100 Subject: [PATCH] Add support for uopz extension handling Introduces handling for the uopz extension to ensure the application does not break due to disabled exit calls by uopz. This change checks for the presence of the uopz extension and its settings, attempting to enable exit calls where possible to maintain application stability. --- CHANGELOG.md | 2 ++ mailscanner/functions.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f8d3543a..78440cb82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## Unreleased +### Added +- Support for handling the `uopz` extension to prevent the application from breaking due to disabled `exit` calls by `uopz`. ## 1.2.22 ### Fixes diff --git a/mailscanner/functions.php b/mailscanner/functions.php index 3830c6622..2eb3d591a 100644 --- a/mailscanner/functions.php +++ b/mailscanner/functions.php @@ -33,6 +33,15 @@ error_reporting(E_ALL ^ E_DEPRECATED ^ E_STRICT); } +if (extension_loaded('uopz') && !(ini_get('uopz.disable') || ini_get('uopz.exit'))) { + // uopz works at opcode level and disables exit calls + if (function_exists('uopz_allow_exit')) { + @uopz_allow_exit(true); + } else { + throw new \RuntimeException('The uopz extension ignores exit calls and breaks this application. Disable the extension or set "uopz.exit" to TRUE'); + } +} + // Read in MailWatch configuration file if (!is_readable(__DIR__ . '/conf.php')) { exit(__('cannot_read_conf'));