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

Don't expose the SQLite3::readOnly method with SQLite < 3.7.4 #3614

Closed
wants to merge 2 commits into from

Conversation

bohwaz
Copy link
Contributor

@bohwaz bohwaz commented Oct 18, 2018

Instead of returning false when the SQLite3 library is too old, just don't expose the method as it doesn't make any sense as the feature is just not present.

…d of returning false, as the underlying function in SQLite3 library is not available
@php-pulls
Copy link

Comment on behalf of petk at php.net:

Labelling... Thank you for the pull request @bohwaz

@cmb69
Copy link
Contributor

cmb69 commented Oct 18, 2018

Thanks! In my opinion, a reasonable improvement. Of course, there is a potential BC break, but since SQLite3 3.7.4 has been released on 2010-12-08, it may not really affect anybody.

@nikic
Copy link
Member

nikic commented Oct 18, 2018

Taking into account that this method is existing since PHP 5.3.7, I think it would be better to stick with the current behavior. The method is documented as

Returns whether a statement is definitely read only. (Emphasis mine.)

which means that it provides a conservative return value. As such, always returning false is a valid (if imprecise) implementation of this method.

Alternatively, we could bump the sqlite version again. sqlite 3.7.4 would be in Ubuntu 12.04 and RHEL 7.

@cmb69
Copy link
Contributor

cmb69 commented Oct 18, 2018

Alternatively, we could bump the sqlite version again. sqlite 3.7.4 would be in Ubuntu 12.04 and RHEL 7.

Would be fine for me, considering that PHP 7.4 is likely to be released roughly nine years after SQLite 3.7.4.

@bohwaz
Copy link
Contributor Author

bohwaz commented Oct 18, 2018

Alternatively, we could bump the sqlite version again. sqlite 3.7.4 would be in Ubuntu 12.04 and RHEL 7.

Would be fine for me, considering that PHP 7.4 is likely to be released roughly nine years after SQLite 3.7.4.

That would be a good solution too.

As for the patch, it was done after a suggestion from @cmb69 on internals, and I find that having false returned when the feature is actually not available is not correct either.

@cmb69
Copy link
Contributor

cmb69 commented Oct 18, 2018

[…] I find that having false returned when the feature is actually not available is not correct either.

I agree, especially since the docs are not correct (sqlite3_stmt_readonly() does not regard user defined functions).

@nikic
Copy link
Member

nikic commented Nov 20, 2018

So, what's the state here? Do we agree that we should raise the libsqlite3 requirement on master and not make this change?

@bohwaz
Copy link
Contributor Author

bohwaz commented Nov 20, 2018

I do agree with raising the libsqlite3 requirement and ditch my PR.

But a similar issue might be raised with other features such as #3669 where I raise an error when the libsqlite3 is too old, but I'm not sure if it's the best practice either.

@cmb69
Copy link
Contributor

cmb69 commented Nov 20, 2018

Raising the requirement to SQLite 3.7.4 as of PHP 7.4.0 still seems good to me.

The currently proposed behavior for SQLite::getSQL(true) for old libsqlite3 versions appears fine to me; there is no fatal error, and not even an exception unless users explicitly opt-in to exceptions in which case they should be prepared that the function may throw, anyway.

@nikic
Copy link
Member

nikic commented Nov 26, 2018

I think raising an exception for unavailable functionality is fine generally (not much else you can do...) My concern here was just the BC break, which doesn't exist for new functions :)

php-pulls pushed a commit that referenced this pull request Nov 29, 2018
`SQLite3::readOnly()` uses `sqlite3_stmt_readonly()` which is only
available as of libsqlite 3.7.4.  For older SQLite3 versions we return
always `false`, which can be confusing.  Instead of sticking with this
behavior, or even undefining the method for old SQLite3 versions, we
lift the requirements to SQLite 3.7.4 (released on 2010-12-08),
according to a respective discussion[1].

Since pdo_sqlite doesn't use `sqlite3_stmt_readonly()`, we stick with
the minimum requirement of SQLite 3.5.0.

[1] <#3614>
@cmb69
Copy link
Contributor

cmb69 commented Nov 29, 2018

I've bumped the ext/sqlite3 requirements now (a757ebb), so this PR is obsolete.

@cmb69 cmb69 closed this Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants