Skip to content

Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3 #14930

Closed
@joec4i

Description

@joec4i

Description

The following code:

class DummyWrapper
{
    public $context;
    public const TEST_FILENAME = 'ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3aiyeejair4dau4osai1si9laeZaiquoopomomai5eeMoce0oecietu';

    public function dir_opendir()
    {
        return true;
    }

    public function dir_readdir()
    {
        return self::TEST_FILENAME;
    }
}


stream_wrapper_register('dummy', 'DummyWrapper');

$dh = opendir('dummy://', stream_context_create());
$file = readdir($dh);

var_dump($file);
var_dump(DummyWrapper::TEST_FILENAME);

Resulted in this output:

➜  /tmp php stream_wrapper.php
/private/tmp/stream_wrapper.php:25:
string(255) "ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3aiyeejair"
/private/tmp/stream_wrapper.php:26:
string(300) "ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3aiyeejair4dau4osai1si9laeZaiquoopomomai5eeMoce0oecietu"
➜  /tmp php -v
PHP 8.3.9 (cli) (built: Jul  2 2024 14:10:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.9, Copyright (c) Zend Technologies
    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies

But I expected this output instead:

➜  /tmp /opt/homebrew/Cellar/php@8.2/8.2.21/bin/php stream_wrapper.php
/private/tmp/stream_wrapper.php:25:
string(300) "ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3aiyeejair4dau4osai1si9laeZaiquoopomomai5eeMoce0oecietu"
/private/tmp/stream_wrapper.php:26:
string(300) "ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3aiyeejair4dau4osai1si9laeZaiquoopomomai5eeMoce0oecietu"
➜  /tmp /opt/homebrew/Cellar/php@8.2/8.2.21/bin/php -v
PHP 8.2.21 (cli) (built: Jul  2 2024 12:51:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.21, Copyright (c) Zend Technologies
    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.2.21, Copyright (c), by Zend Technologies

PHP Version

PHP 8.3.9

Operating System

Reproducible on both macOS and Debian Buster / Bookworm.

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