Skip to content
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

Drop usages of E_RECOVERABLE_ERROR #6106

Closed
wants to merge 32 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 9, 2020

There were only 2 remaining usages.

As from comment #6049 (comment)

ext/session/session.c Outdated Show resolved Hide resolved
@Girgias Girgias force-pushed the recoverable-error-to-proper-error branch from 717fe60 to f71484b Compare September 10, 2020 00:52
@@ -2540,7 +2540,7 @@ ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */
if (zobj->handlers->cast_object(zobj, &tmp, _IS_BOOL) == SUCCESS) {
return Z_TYPE(tmp) == IS_TRUE;
}
zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name));
zend_type_error("Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name));
Copy link
Member

Choose a reason for hiding this comment

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

This is generally fine, but we will need to perform an exception-safety audit on all users for zend_is_true/zval_is_true.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how feasible it is do perform this before next Tuesday when RC1 gets tagged as there does seems to be a couple of crucial usages (zend_compare, OpCache) looking at: https://heap.space/search?project=php-src&refs=zval_is_true and https://heap.space/search?project=php-src&refs=zend_is_true

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I've checked all of them but I'm very unsure about how to go about it with some cases.

@Girgias Girgias force-pushed the recoverable-error-to-proper-error branch 2 times, most recently from 762a98b to f9e0482 Compare September 15, 2020 01:05
@Girgias Girgias force-pushed the recoverable-error-to-proper-error branch 3 times, most recently from 0716269 to 16a0b30 Compare September 23, 2020 18:50
@Girgias Girgias requested a review from nikic September 27, 2020 20:58
@nikic
Copy link
Member

nikic commented Sep 27, 2020

I think we need to punt this one to 8.1.

@@ -604,8 +604,18 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
break;
}
ZVAL_BOOL(result, zend_is_true(&op2));
/* op2 is an object which cannot be converted to bool */
Copy link
Member

Choose a reason for hiding this comment

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

Objects definitely can't occur in this context.

@Girgias Girgias added this to the PHP 8.1 milestone Sep 27, 2020
@GrahamCampbell
Copy link
Contributor

If RC1 is delayed by 2 weeks, it is feasible for this to make it into 8.0?

@krakjoe
Copy link
Member

krakjoe commented May 11, 2021

@Girgias what's the status on this one ? milestone coming up ...

@Girgias
Copy link
Member Author

Girgias commented May 11, 2021

@Girgias what's the status on this one ? milestone coming up ...

I'll have another look at this within this week, thanks for reminding me.

@ramsey
Copy link
Member

ramsey commented Jun 9, 2021

8.1.0alpha1 is out this week. How's this looking for inclusion in a future 8.1 milestone release?

@Girgias Girgias force-pushed the recoverable-error-to-proper-error branch from 8ce4e2a to ff0cf44 Compare June 17, 2021 01:59
This was referenced Jun 17, 2021
@Girgias Girgias force-pushed the recoverable-error-to-proper-error branch from ff0cf44 to e657b50 Compare July 10, 2021 17:28
Comment on lines +19 to +21
$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val boolean)');
$db->exec('INSERT INTO test VALUES(1, TRUE)');
$db->exec('INSERT INTO test VALUES(2, FALSE)');
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this test case. I think this test case should be present in every driver separately as some of them have the boolean type and some don't. Also, binding using PDO::PARAM_BOOL might not be properly supported for some of them. I'd also expect this test case to happen with emulated and without emulated prepares.

The exception checking you have added looks like the wrong solution. See MySQL execution for example, which silently fails and causes a syntax error. We don't want to do that. It's just my opinion, what's yours?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some of the tests in ext/pdo are skipped for certain drivers (namely OCI) and I prefer doing this because if a new driver gets added/modified we'll know this case will be handled.

The exception check might be incorrect because I blindly added it everywhere where a call which could throw comes up, so any improvements are welcomed. :-)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then how about instead of using boolean data type, use int instead. I think it's more widely supported. Then also you can change TRUE/FALSE to 1/0.

@@ -259,6 +259,10 @@ safe:
switch (param_type) {
case PDO_PARAM_BOOL:
plc->quoted = zend_is_true(parameter) ? ZSTR_CHAR('1') : ZSTR_CHAR('0');
// TODO Can an exception occur here?
if (EG(exception)) {
Copy link
Member

Choose a reason for hiding this comment

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

How about adding ret = -1; here to at least stop the execution?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's probably even necessary, been a while since I looked at this code.

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

There has not been any recent activity in this PR. It will automatically be closed in 7 days if no further action is taken.

@github-actions github-actions bot added the Stale label Feb 8, 2022
@github-actions github-actions bot closed this Feb 16, 2022
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.

None yet

6 participants