php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75869 mysqli_driver is monostate
Submitted: 2018-01-24 17:52 UTC Modified: 2020-03-14 15:31 UTC
From: xavier dot leune at gmail dot com Assigned: cmb (profile)
Status: Closed Package: MySQLi related
PHP Version: 7.2.1 OS: Ubuntu 17.04
Private report: No CVE-ID: None
 [2018-01-24 17:52 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-06 09:20 UTC] cmb@php.net
-Summary: Lack of isolation on mysqli_driver->report_mode +Summary: mysqli_driver is monostate -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-03-06 09:20 UTC] 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>
 [2020-03-14 15:28 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349423
Log: Fix #75869: mysqli_driver is monostate
 [2020-03-14 15:30 UTC] phpdocbot@php.net
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
 [2020-03-14 15:30 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-03-14 15:31 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-03-14 22:34 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349434
Log: Fix #75869: mysqli_driver is monostate
 [2020-03-14 22:35 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=cc8beeb0e6f718c32a492abfa1da34b226830fab
Log: Fix #75869: mysqli_driver is monostate
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Sep 23 04:01:25 2020 UTC