Skip to content

zend_execute: Suppress values in UnhandledMatchError for zend.exception_ignore_args=1 #17619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.3.18

- Core:
Fixed bug GH-17618 (UnhandledMatchError does not take
zend.exception_ignore_args=1 into account). (timwolla)

13 Feb 2025, PHP 8.3.17

Expand Down
42 changes: 42 additions & 0 deletions Zend/tests/match/049.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
Match expression error messages (zend.exception_ignore_args=1)
--INI--
zend.exception_ignore_args=1
--FILE--
<?php

class Beep {}

function test(mixed $var) {
try {
match($var) {};
} catch (UnhandledMatchError $e) {
print $e->getMessage() . PHP_EOL;
}
}

test(null);
test(1);
test(5.5);
test(5.0);
test("foo");
test(true);
test(false);
test([1, 2, 3]);
test(new Beep());
// Testing long strings.
test(str_repeat('e', 100));
test(str_repeat("e\n", 100));
?>
--EXPECT--
Unhandled match case of type null
Unhandled match case of type int
Unhandled match case of type float
Unhandled match case of type float
Unhandled match case of type string
Unhandled match case of type bool
Unhandled match case of type bool
Unhandled match case of type array
Unhandled match case of type Beep
Unhandled match case of type string
Unhandled match case of type string
2 changes: 1 addition & 1 deletion Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ ZEND_COLD void zend_match_unhandled_error(const zval *value)
{
smart_str msg = {0};

if (Z_TYPE_P(value) <= IS_STRING) {
if (!EG(exception_ignore_args) && Z_TYPE_P(value) <= IS_STRING) {
smart_str_append_scalar(&msg, value, EG(exception_string_param_max_len));
} else {
smart_str_appendl(&msg, "of type ", sizeof("of type ")-1);
Expand Down
Loading