Doc #75869 [Ver->Csd]: mysqli_driver is monostate
Edit report at https://bugs.php.net/bug.php?id=75869&edit=1
ID: 75869
Updated by: phpdocbot@php.net
Reported by: xavier dot leune at gmail dot com
Summary: mysqli_driver is monostate
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: MySQLi related
Operating System: Ubuntu 17.04
PHP Version: 7.2.1
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=ad878b0b20bef6893c359528f80ebc2d41be301f
Log: Fix #75869: mysqli_driver is monostate
Previous Comments:
------------------------------------------------------------------------
[2020-03-14 15:28:48] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349423
Log: Fix #75869: mysqli_driver is monostate
------------------------------------------------------------------------
[2020-03-06 09:20:43] cmb@php.net
The mysqli_driver class is an instance of the monostate
pattern[1], i.e. there is only one driver which can be accessed
though an arbitrary amount of mysqli_driver instances. It would
have been less confusing to implement that as a set of plain
functions.
Anyhow, this is unlikely to change, but needs to be documented.
[1] <https://wiki.c2.com/?MonostatePattern>
------------------------------------------------------------------------
[2018-01-24 17:52:55] xavier dot leune at gmail dot com
Description:
------------
Hi there,
When changing the report_mode of an instance of mysqli_driver, all instances (already created or
future instances) will share the same value of report_mode.
This can be very annoying when a 3rd party library enables the exceptions on mysqli, if some other
3rd party library makes the assumption that the report_mode is to it's default value.
Thanks,
Xavier.
Test script:
---------------
https://gist.github.com/xavierleune/8cde9fc97ea7136d425a1d63cbb974fb
Expected result:
----------------
$tainted->report_mode: int(2)
$original->report_mode: int(0)
Actual result:
--------------
$tainted->report_mode: int(2)
$original->report_mode: int(2)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75869&edit=1
Thread (2 messages)