PDOStatement::$queryString "readonly" is not properly implemented
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.2k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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:
https://github.com/php/php-src/blob/209e0d6ad29b1f49982c58088aadd9d1ad86a162/ext/pdo/pdo_stmt.c#L2008-L2014
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo ext/pdo/pdo_stmt.c alle righe collegate ed esegui la riproduzione dell'issue. È completato quando le assegnazioni ripetute a PDOStatement::$queryString non eludono più il controllo readonly e producono l'Error previsto; una pull request aperta risolve già questo problema.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, php
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 30/100