Skip to content

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Nov 2, 2025

No description provided.

Copy link
Member

@Girgias Girgias left a 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 :)

Comment on lines 1909 to 1911
if (!ZSTR_LEN(sql)) {
RETURN_FALSE;
}
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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.

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 seen this somewhere else before too

Comment on lines 1917 to 1920
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;
}
Copy link
Member

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.

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 would break people using a combination of reflection+manual __construct calls

@ndossche ndossche merged commit 197a455 into php:master Nov 2, 2025
10 checks passed
@ndossche
Copy link
Member Author

ndossche commented Nov 2, 2025

In any case I merged this as this is correct as-is.

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.

3 participants