From 6ccb4788f6c44e8c67e27507e36ebe583a6a0d86 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 2 Mar 2015 12:16:05 +0100 Subject: Improve assertion handling Enable it explicitly and make sure a failed assertion will always terminate execution. Signed-off-by: Florian Pritz --- index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.php b/index.php index ebf1667e6..a88fcb21e 100644 --- a/index.php +++ b/index.php @@ -297,6 +297,14 @@ function check_for_fatal() } register_shutdown_function("check_for_fatal"); +function _assert_failure($file, $line, $expr, $message = "") +{ + _actual_exception_handler(new Exception("assert($expr): Assertion failed in $file at line $line".($message != "" ? " with message: '$message'" : ""))); + exit(1); +} + +assert_options(ASSERT_ACTIVE, true); +assert_options(ASSERT_CALLBACK, '_assert_failure'); /* * -------------------------------------------------------------------- * LOAD THE BOOTSTRAP FILE -- cgit v1.2.3-24-g4f1b