Skip to content

Minor refactorings to zend_exceptions() - #16684

Merged
Girgias merged 2 commits into
php:masterfrom
Girgias:exceptions-refacto
Nov 10, 2024
Merged

Minor refactorings to zend_exceptions()#16684
Girgias merged 2 commits into
php:masterfrom
Girgias:exceptions-refacto

Conversation

@Girgias

@Girgias Girgias commented Nov 2, 2024

Copy link
Copy Markdown
Member

I was planning on removing a bunch of zval_get_long() and zval_get_string() calls to properties as those are typed properties, however not sure it is wise to remove them as ArrayObject can in theory mess them up.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, only some remark about comments

Comment thread Zend/zend_exceptions.c Outdated
if (file) {
if (Z_TYPE_P(file) != IS_STRING) {
if (UNEXPECTED(Z_TYPE_P(file) != IS_STRING)) {
/* This is a typed property and can only happen if modified via ArrayObject */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true, see bug63762.phpt in Zend

Comment thread Zend/zend_exceptions.c Outdated
if (EXPECTED(Z_TYPE_P(tmp) == IS_LONG)) {
line = Z_LVAL_P(tmp);
} else {
/* This is a typed property and can only happen if modified via ArrayObject */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely not true as well due to similar reasons as bug63762.phpt in Zend

Comment thread Zend/zend_exceptions.c Outdated
ZSTR_LEN(str->s) -= 2; /* remove last ', ' */
}
} else {
/* The trace property is typed and private */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check with bug63762.phpt in Zend

@Girgias
Girgias merged commit 23b8d64 into php:master Nov 10, 2024
@Girgias
Girgias deleted the exceptions-refacto branch November 10, 2024 21:44
DanielEScherzer added a commit to DanielEScherzer/php-src that referenced this pull request Aug 3, 2026
In addition to the fixes within the reflection extension, support for error
strings with null bytes was added to `zend_throw_error()` and
`zend_throw_exception_ex()`. The changes to `zend_throw_exception_ex()` are a
partial backport of php#16684.
adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants