Re: Changing the default value of SQLite3::enableExceptions()

This is only part of a thread. view whole thread
  105742
May 18, 2019 10:00 cmbecker69@gmx.de ("Christoph M. Becker")
On 17.05.2019 at 21:42, Kalle Sommer Nielsen wrote:

> While reviewing a PR[1], which proposes to add two new methods to > ext/sqlite3, one being an option to toggle on/off, I've noticed that > there already is another method which also enables the extension to > toggle on/off behavior, in this case; whether or not to throw > exceptions instead of warnings. > > This method have a rather poor naming considering its default value.
ACK.
> Observe the current prototype: > SQLite3::enableExceptions ([ bool $enableExceptions = FALSE ] ) : bool > > What this means is that code like this may not do what you actually > think it does: > $link->enableExceptions(); > > Due to the $enableExceptions parameter being default to false. I'm > writing this email to get some feedback on thoughts regarding changing > this default value to true (current thinking is PHP8) or simply > dropping the default value, forcing users to specify whether or not to > enable exception mode. > > I personally think its better to simply deal with the default value > rather than making a bigger potential BC break by renaming the method > to something like: SQLite3::toggleExceptions()
ACK. However, I don't think that we can change the default value in the near future for BC reasons. Deprecating (7.4) and removing support (8.0) for calling the method without argument would be the way to go, I think. [In a somewhat distant future, we might consider reintroducing support for argument-less calls, but in this case it might make sense to let the method work as getter (i.e. without argument, it would return the current value without changing it).] Thanks, Christoph
  105753
May 18, 2019 23:56 kalle@php.net (Kalle Sommer Nielsen)
Hi Christoph

Den lør. 18. maj 2019 kl. 13.00 skrev Christoph M. Becker <cmbecker69@gmx.de>:
> However, I don't think that we can change the default value in the near > future for BC reasons. Deprecating (7.4) and removing support (8.0) for > calling the method without argument would be the way to go, I think.
Yeah I agree here. We could go a similar around to what you proposed for the curl version function, something like (for PHP-7.4): if (ZEND_NUM_ARGS() == 0) { /* E_DEPRECATED: Relying on the default value of $enableExceptions is deprecated as it will change from FALSE to TRUE ...*/ } And for master simply making the parameter required. I suspect the impact of this is very minimal as most users of this would not be affected by this proposal unless its a bug in their code (as I don't expect anyone to call ->enableExceptions() to *disable* them being anything but a bug).
> [In a somewhat distant future, we might consider reintroducing support > for argument-less calls, but in this case it might make sense to let the > method work as getter (i.e. without argument, it would return the > current value without changing it).]
Currently SQLite3::enableExceptions() will return the old value, I think we should retain this and only change the default value. -- regards, Kalle Sommer Nielsen kalle@php.net