Skip to content

Convert usage of php_error/zend_error to php_error_docref - #22927

Draft
NattyNarwhal wants to merge 13 commits into
php:masterfrom
NattyNarwhal:zend-error-cleanup
Draft

Convert usage of php_error/zend_error to php_error_docref#22927
NattyNarwhal wants to merge 13 commits into
php:masterfrom
NattyNarwhal:zend-error-cleanup

Conversation

@NattyNarwhal

@NattyNarwhal NattyNarwhal commented Jul 29, 2026

Copy link
Copy Markdown
Member

Not yet complete, likely adding more. Some notes so far:

  • The goal is to eventually eliminate php_error as an alias for zend_error, make error reporting more consistent, and eventually figure out some symmetry between php_verror and php_error_docref naming wise. zend_error should remain, but there may be quite a bit of overlap anyways.
  • I'm starting with ext since this usually is for functions where the php_error_docref output makes sense when prefixing with a function name and optionally arguments (or indicating phase of startup/shutdown). There are some notable exceptions (some stuff related to arrays and comparisons) that do not work in that context.
    • There may be some stuff in Zend and sapi too.
  • Deprecation messages tend to repeat the function name, so I haven't changed those. Perhaps there should be some kind of function for consistent deprecation messages?
  • The changes to ext/soap are a bit wider, getting rid of some pointless macros and replacing the SOAP-ERROR prefix with the function prefix from docref output. This could be broken out into a separate PR.
  • A lot are in hard to reach areas without tests to validate. Some of these may make more sense as exceptions, for instance.
  • There's also some fprintf with stderr; usually in #if DEBUG type code. Worth changing?

@Girgias Girgias 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.

I think the exif, sodium, pdo, pdo_sqlite, net_get_interface, ini_parse_quantity, auto_detect_line_ending, and math can all land.

Comment thread ext/soap/tests/bugs/bug50698_2.phpt Outdated

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.

The faultstring here should be updated.

Comment thread ext/soap/tests/bugs/bug50698_3.phpt Outdated

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.

Ditto

Comment thread ext/soap/tests/bugs/bug62900.phpt Outdated
?>
--EXPECTF--
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from '%sbug62900.xsd', unexpected 'targetNamespace'='http://www.w3.org/XML/1998/namespacex', expected 'http://www.w3.org/XML/1998/namespace' in %s:%d
Fatal error: Uncaught SoapFault exception: [WSDL] SoapClient::__construct(): SOAP-ERROR: Parsing Schema: can't import schema from '/Users/calvin/src/php-src/ext/soap/tests/bugs/bug62900.xsd', unexpected 'targetNamespace'='http://www.w3.org/XML/1998/namespacex', expected 'http://www.w3.org/XML/1998/namespace' in %s:%d

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.

Your local path is leaking in this test.

Comment thread ext/soap/php_soap.h
Comment on lines -200 to -210
#define soap_error0(severity, format) \
php_error(severity, "SOAP-ERROR: " format)

#define soap_error1(severity, format, param1) \
php_error(severity, "SOAP-ERROR: " format, param1)

#define soap_error2(severity, format, param1, param2) \
php_error(severity, "SOAP-ERROR: " format, param1, param2)

#define soap_error3(severity, format, param1, param2, param3) \
php_error(severity, "SOAP-ERROR: " format, param1, param2, param3)

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.

Might make sense to first have a PR that converts those macro variants to a single one, and then do the docref conversion in a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll try to break this up better in a separate PR, since the history of this one is a little weird anyways

Comment thread ext/standard/browscap.c Outdated
zend_string_equals_ci(ctx->current_section_name, Z_STR_P(arg2))
) {
zend_error(E_CORE_ERROR, "Invalid browscap ini file: "
php_error_docref(NULL, E_CORE_ERROR, "Invalid browscap ini file: "

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.

Not exactly sure how the docref should be written but I thinki: "misc.configuration.php#ini.browscap" might work?

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