Exclusive locks are not supported for this stream `php://stdout`
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
Description
I wonder why the file_put_contents emitts a Exclusive locks are not supported for this stream error and putting the very same stream into stream_supports_lock does not return false, but also errors.
The following code:
<?php
var_dump(stream_supports_lock("php://stdout"));
file_put_contents(
"php://stdout",
"x",
FILE_APPEND | LOCK_EX,
);
Resulted in this output:
$ php test.php
PHP Fatal error: Uncaught TypeError: stream_supports_lock(): Argument #1 ($stream) must be of type resource, string given in C:\dvl\Workspace\phpunit\test.php:3
Stack trace:
#0 C:\dvl\Workspace\phpunit\test.php(3): stream_supports_lock()
#1 {main}
thrown in C:\dvl\Workspace\phpunit\test.php on line 3
Fatal error: Uncaught TypeError: stream_supports_lock(): Argument #1 ($stream) must be of type resource, string given in C:\dvl\Workspace\phpunit\test.php:3
Stack trace:
#0 C:\dvl\Workspace\phpunit\test.php(3): stream_supports_lock()
#1 {main}
thrown in C:\dvl\Workspace\phpunit\test.php on line 3
But I expected this output instead:
$ php test.php
bool(false)
PHP Warning: file_put_contents(): Exclusive locks are not supported for this stream in C:\dvl\Workspace\phpunit\test.php on line 5
Warning: file_put_contents(): Exclusive locks are not supported for this stream in C:\dvl\Workspace\phpunit\test.php on line 5
might be a windows only error, because 3v4l.org does not report the same error
https://3v4l.org/98p6T
PHP Version
$ php -v
PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:35) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
Operating System
windows11
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 riproducendo l'esempio su Windows con PHP 8.2.12 e confronta stream_supports_lock("php://stdout") con file_put_contents(..., FILE_APPEND | LOCK_EX). Verifica il comportamento rispetto al risultato booleano e all'avviso previsti, quindi verifica che lo stesso caso non generi più un TypeError e continui a segnalare che i lock esclusivi non sono supportati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- backend, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100