Skip to content

PHP 8.6 IO Copy API breaks STREAM_NOTIFY_PROGRESS and STREAM_NOTIFY_COMPLETED #22841

Description

@TimWolla

Description

The following code:

<?php

function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
    switch($notification_code) {
        case STREAM_NOTIFY_RESOLVE:
        case STREAM_NOTIFY_AUTH_REQUIRED:
        case STREAM_NOTIFY_FAILURE:
        case STREAM_NOTIFY_AUTH_RESULT:
            var_dump($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max);
            /* Ignore */
            break;

        case STREAM_NOTIFY_COMPLETED:
            echo "Transfer completed with ", $bytes_transferred, " bytes";
            break;

        case STREAM_NOTIFY_REDIRECTED:
            echo "Being redirected to: ", $message;
            break;

        case STREAM_NOTIFY_CONNECT:
            echo "Connected...";
            break;

        case STREAM_NOTIFY_FILE_SIZE_IS:
            echo "Got the filesize: ", $bytes_max;
            break;

        case STREAM_NOTIFY_MIME_TYPE_IS:
            echo "Found the mime-type: ", $message;
            break;

        case STREAM_NOTIFY_PROGRESS:
            echo "Made some progress, downloaded ", $bytes_transferred, " so far";
            break;
    }
    echo "\n";
}

$ctx = stream_context_create();
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
$f = fopen('compress.zlib://http://localhost:8080/index.php.gz', 'r', false, $ctx);
var_dump(trim(stream_get_contents($f)));

running against PHP’s development web server where index.php.gz is equal to the decoded H4sICPQfX2oAA2luZGV4LnBocADzSM3JyVcIzy/KSVHkAgDd3RR9DQAAAA==

Resulted in this output:

Connected...
Found the mime-type: application/gzip
Got the filesize: 43
Made some progress, downloaded 0 so far
string(12) "Hello World!"

But I expected this output instead:

Connected...
Found the mime-type: application/gzip
Got the filesize: 43
Made some progress, downloaded 0 so far
Made some progress, downloaded 43 so far
Transfer completed with 43 bytes
string(12) "Hello World!"

git bisect points to 32a0f3b.

git bisect start
# status: waiting for both good and bad commits
# new: [f6fe838e364943020daf802d8c9f55ef5099cf6f] ext/soap: truncate header values containing newline characters.
git bisect new f6fe838e364943020daf802d8c9f55ef5099cf6f
# status: waiting for good commit(s), bad commit known
# old: [c4612661aeec14f73463df6ade72c04f232182fc] Merge branch 'PHP-8.5'
git bisect old c4612661aeec14f73463df6ade72c04f232182fc
# new: [55183b9d127bb8eba2d5e4b13e0c1536ff371d30] poll: fetch method ptr directly (#22816)
git bisect new 55183b9d127bb8eba2d5e4b13e0c1536ff371d30
# new: [c06e86d9cad7749e5800f7126c41858b9586e060] Reflection: consistent pointer type declaration spacing
git bisect new c06e86d9cad7749e5800f7126c41858b9586e060
# new: [fdc5b8f952cf5ea2a1b9b838f8e36847e2f76b1b] Reorganise UPGRADING.INTERNALS to be more legible (#22808)
git bisect new fdc5b8f952cf5ea2a1b9b838f8e36847e2f76b1b
# new: [32a0f3b6cfdee8ae4781121e864fd0b1837ecbe4] IO copy API for stream copying (#20399)
git bisect new 32a0f3b6cfdee8ae4781121e864fd0b1837ecbe4
# old: [34c686a5b4ef10fd2451deb52422b410d4c7d619] stream: remove path parameter in stream error functions (#22792)
git bisect old 34c686a5b4ef10fd2451deb52422b410d4c7d619
# first new commit: [32a0f3b6cfdee8ae4781121e864fd0b1837ecbe4] IO copy API for stream copying (#20399)

PHP Version

see bisect

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions