Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented May 6, 2021

Those branches and/or functions are only called from the OOP/constructor API as such there is no need to use zend_replace_error_handling().

One usage of this remains in the timezone_initialize() which could have a parameter added to signal if it should throw directly.

@Girgias Girgias force-pushed the date-throw-exception-directly branch from 63b440f to 7988eaf Compare May 6, 2021 20:34
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) {
/* spit out the first library error message, at least */
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", time_str,
zend_throw_error(zend_ce_exception, "Failed to parse time string (%s) at position %d (%c): %s", time_str,
Copy link
Member

Choose a reason for hiding this comment

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

Should be zend_throw_exception_ex, same for the others.

/* }}} */

static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length) /* {{{ */
static void date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length) /* {{{ */
Copy link
Member

Choose a reason for hiding this comment

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

I think it would have been nicer to retain the return value and check that instead of EG(exception).

@Girgias Girgias force-pushed the date-throw-exception-directly branch from 7988eaf to dc6703c Compare May 7, 2021 10:02
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) {
/* spit out the first library error message, at least */
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", time_str,
zend_throw_exception_ex(NULL, 0, "Failed to parse time string (%s) at position %d (%c): %s", time_str,
Copy link
Member Author

Choose a reason for hiding this comment

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

Should I keep E_WARNING as the Exception code?

Copy link
Member

Choose a reason for hiding this comment

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

No, we don't use exception codes.

@Girgias Girgias merged commit 2f1d0f2 into php:master May 7, 2021
@Girgias Girgias deleted the date-throw-exception-directly branch May 7, 2021 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants