Description
Symfony version(s) affected
6.0.3
Description
The mysqli_driver
class implements what's documented as a monostate pattern: every instance of that class shares the same state.
As shown at mysqli_driver.c, properties are checked when they are accessed, not at object initialization.
When dumping, the clone ignores some values but more importantly, puts a 0 value for report_mode instead the actual reporting value configured.
How to reproduce
Code
$driver = new mysqli_driver();
$driver->report_mode = 3;
dump($driver);
Expected
An output similar to var_dump($driver)
:
^ mysqli_driver {#2663
+client_info: mysqlnd 8.1.1
+client_version: 80101
+reconnect: false
+report_mode: 3
}
Actual
^ mysqli_driver {#2663
+reconnect: false
+report_mode: 0
}
Possible Solution
The cloner mechanism could detect such classes with an allowlist of them (currently that list will be short: ["mysqli_driver"]) and query the properties each time they need to be accessed instead of trying to store and determine a value.
Additional Context
Initially detected in psysh: bobthecow/psysh#706