Req #71150 [Opn->Fbk]: Calling SQLite3::enableExceptions returns previous value instead of new value

From: Date: Fri, 02 Sep 2016 19:20:31 +0000
Subject: Req #71150 [Opn->Fbk]: Calling SQLite3::enableExceptions returns previous value instead of new value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203757@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71150&edit=1 ID: 71150 Updated by: cmb@php.net Reported by: bill at zeroedin dot com Summary: Calling SQLite3::enableExceptions returns previous value instead of new value -Status: Open +Status: Feedback Type: Feature/Change Request Package: SQLite related PHP Version: master-Git-2015-12-17 (Git) -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: After further consideration I don't think that changing the behavior of SQLite3::enableException() is viable (at least not without an explicit RFC) due to BC concerns. Furthermore, getting the current state seems to be rarely needed, and if one needs it, one could still write a function in userland: <?php function exceptions_enabled() { $current = SQLite3::enableException(); SQLite3::enableException($current); return $current; } Previous Comments: ------------------------------------------------------------------------ [2016-06-27 15:32:22] cmb@php.net Indeed, this is not a bug, because $enable defaults to false, and as such the method is not overloaded to work as getter and setter. > The behavior should be changed to match other similar methods on > other drivers. Do other "drivers" work otherwise? Anyhow, I'm changing to feature request. ------------------------------------------------------------------------ [2015-12-18 02:58:20] laruence@php.net SQLite3::enableException($enable = false); it returns previously value of enableexception, which default to false. thanks ------------------------------------------------------------------------ [2015-12-17 16:30:10] bill at zeroedin dot com Description: ------------ I am documenting the previously undocumented method SQLite3::enableExceptions, and I notice that the method has some weird behavior. Currently, if you call enableExceptions(true) and exceptions were previously disabled, it returns false. The inverse is also true. If you call enableExceptions(), it turns off exceptions for the driver and returns whatever value was previously set. The behavior should be changed to match other similar methods on other drivers. The method should only change the exception behavior if the $enableExceptions parameter is true or false passed by the user. If no value is passed, the method should return the current state of the flag and take no action. When $enableExceptions is passed by the user, the method should set the value and then return the new value. Test script: --------------- $sqlite3 = new SQLite3(':memory:'); var_dump($sqlite3->enableExceptions(true)); var_dump($sqlite3->enableExceptions()); var_dump($sqlite3->enableExceptions()); var_dump($sqlite3->enableExceptions(false)); var_dump($sqlite3->enableExceptions()); var_dump($sqlite3->enableExceptions()); Expected result: ---------------- bool(true) bool(true) bool(true) bool(false) bool(false) bool(false) Actual result: -------------- bool(false) bool(true) bool(false) bool(false) bool(false) bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71150&edit=1

« previous php.bugs (#203757) next »