]> granicus.if.org Git - php/commitdiff
Promote register_tick_function() callback validation warning to an exception
authorMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 7 Nov 2019 00:11:57 +0000 (01:11 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 7 Nov 2019 16:56:58 +0000 (17:56 +0100)
ext/standard/basic_functions.c
ext/standard/tests/general_functions/register_tick_function_error.phpt [new file with mode: 0644]

index b11311b51c09ea15149409a1bc64f5afd400ab92..b405842c01e036d7f497c9228e2ab3a8ec2ad900 100755 (executable)
@@ -4278,9 +4278,9 @@ PHP_FUNCTION(register_tick_function)
 
        if (!zend_is_callable(&tick_fe.arguments[0], 0, &function_name)) {
                efree(tick_fe.arguments);
-               php_error_docref(NULL, E_WARNING, "Invalid tick callback '%s' passed", ZSTR_VAL(function_name));
+               zend_type_error("Invalid tick callback '%s' passed", ZSTR_VAL(function_name));
                zend_string_release_ex(function_name, 0);
-               RETURN_FALSE;
+               return;
        } else if (function_name) {
                zend_string_release_ex(function_name, 0);
        }
diff --git a/ext/standard/tests/general_functions/register_tick_function_error.phpt b/ext/standard/tests/general_functions/register_tick_function_error.phpt
new file mode 100644 (file)
index 0000000..b71f1ea
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+register_tick_function only accepts a valid callback as parameter
+--FILE--
+<?php
+declare(ticks=1);
+
+try {
+    register_tick_function("a");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+?>
+--EXPECT--
+Invalid tick callback 'a' passed