Skip to content

Internal stream casting should not emit lost bytes warning twice #10092

Closed
@Girgias

Description

@Girgias

Description

The following code:

<?php
$handle = fopen('http://example.com', 'r');
var_dump(stream_isatty($handle));

Resulted in this output:


Warning: stream_isatty(): 1256 bytes of buffered data lost during stream conversion! in test.php on line 3

Warning: stream_isatty(): 1256 bytes of buffered data lost during stream conversion! in test.php on line 3
bool(false)

But I expected this output instead:


Warning: stream_isatty(): 1256 bytes of buffered data lost during stream conversion! in test.php on line 3
bool(false)

Or ideally:

bool(false)

The thing is that if one reads the original stream via:

$contents = '';
while (!feof($handle)) {
    $contents .= fread($handle, 8192);
}
var_dump($contents);

One does get the totality of the 1256 bytes of output.
So I'm confused as to why the warning is emitted in the first place.

PHP Version

master

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions