Open
Description
Description
The following code:
<?php
$stmt = new PDOStatement();
var_dump($stmt);
for($i=0;$i<10;$i++)
$stmt->queryString = (string) $i;
var_dump($stmt);
Resulted in this output:
object(PDOStatement)#1 (0) {
["queryString"]=>
uninitialized(string)
}
object(PDOStatement)#1 (1) {
["queryString"]=>
string(1) "9"
}
But I expected this output instead:
object(PDOStatement)#1 (0) {
["queryString"]=>
uninitialized(string)
}
Fatal error: Uncaught Error: Property queryString is read only in x.php:5
The reason this happens is because the following code is wrong:
Lines 2008 to 2014 in 209e0d6
The second loop iteration just reuses the cache slot and won't go through the write handler, bypassing the fake readonly check.
Either this should be relaxed or be fixed (i.e. "real readonly").
PHP Version
8.3+
Operating System
No response