From 572e1c052267cd34cbedfcb7d51cda35a55667c1 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 9 Nov 2020 16:23:49 +0100 Subject: detect bad it::error usage --- it.class | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/it.class b/it.class index 7ef1d28..74c9b7c 100644 --- a/it.class +++ b/it.class @@ -155,12 +155,15 @@ static function timerlog($label = '') * |graceperiod|timewindow|------> * id x x x m x x x x */ -static function error($p = array()) +static function error($p = array(), $extra = null) { $p = $origp = (array)$p; $p['title'] = $p[0] ?: $p['title']; # handle 'it_error' => "oops" that was cast to array on the way $p['title'] = grapheme_substr($p['title'], 0, 2000); + if ($extra) + it::error('extraneous params passed to it::error'); + foreach (array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10), 1) as $level) if ($level["class"] . $level["type"] . $level["function"] == "it::error") return null; # prevent recursion -- cgit v1.2.3