-
Notifications
You must be signed in to change notification settings - Fork 8k
sqlite3: remove nonsensical return_value dtor #20360
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring looks correct, except I think there are bigger problems here :)
| if (!ZSTR_LEN(sql)) { | ||
| RETURN_FALSE; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong? As this is a constructor and the return value is never used normally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call __construct manually, which is why this has return values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can yes, but the expectation is that there is no meaningful return value and you just call parent::__construct(). I don't think any other internal classes (even those that you can subclass) have those semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've seen this somewhere else before too
| if (errcode != SQLITE_OK) { | ||
| php_sqlite3_error(db_obj, errcode, "Unable to prepare statement: %s", sqlite3_errmsg(db_obj->db)); | ||
| zval_ptr_dtor(return_value); | ||
| RETURN_FALSE; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, this is a constructor so it should throw on error rather than creating a non-usable object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would break people using a combination of reflection+manual __construct calls
|
In any case I merged this as this is correct as-is. |
No description provided.