Exclusive locks are not supported for this stream `php://stdout`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.2k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Beispiel unter Windows mit PHP 8.2.12 zu reproduzieren und stream_supports_lock("php://stdout") mit file_put_contents(..., FILE_APPEND | LOCK_EX) zu vergleichen. Überprüfe das Verhalten anhand des erwarteten booleschen Ergebnisses und der Warnung und verifiziere anschließend, dass derselbe Fall keinen TypeError mehr auslöst und weiterhin meldet, dass exklusive Sperren nicht unterstützt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- backend, operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100