From eecd35d175339822e7267adda3fd2c74fc0a5737 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 24 Jun 2020 12:44:17 +0100 Subject: [PATCH] turn 'Use of undefined constant' into an error --- core/util.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/util.php b/core/util.php index f1a437a1..94a5f663 100644 --- a/core/util.php +++ b/core/util.php @@ -582,6 +582,15 @@ date and you should plan on moving elsewhere. if (DEBUG) { error_reporting(E_ALL); } + set_error_handler(function ($errNo, $errStr) { + // Should we turn ALL notices into errors? PHP allows a lot of + // terrible things to happen by default... + if (strpos($errStr, 'Use of undefined constant ') === 0) { + throw new Exception("PHP Error#$errNo: $errStr"); + } else { + return false; + } + }); // The trace system has a certain amount of memory consumption every time it is used, // so to prevent running out of memory during complex operations code that uses it should