#40656 [NEW]: DOMDocument::load() does not support stream wrappers

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40656 [NEW]: DOMDocument::load() does not support stream wrappers

    From: bugs at php dot frankkleine dot de
    Operating system: irrelevant
    PHP version: 5.2.1
    PHP Bug Type: Feature/Change Request
    Bug description: DOMDocument::load() does not support stream wrappers

    Description:
    ------------
    The DOMDocument::load() method does not support working with stream
    wrappers. It's an inconsistency within PHP, one would expect that this
    method works with stream wrappers as well just as other methods and
    functions do.

    Reproduce code:
    ---------------
    class MyStreamWrapper
    {
    protected $read = false;
    protected $stream = '<?xml version="1.0"
    encoding="iso-8859-1"?><foo><bar id="1">hello world</bar></foo>';
    public function stream_open($path, $mode, $options, $opened_path)
    {return true; }
    public function stream_close() { }
    public function stream_read($count)
    {
    if (true == $this->read) { return ''; }
    $this->read = true;
    return $this->stream;
    }
    public function stream_eof() { return $this->read; }
    public function stream_stat() { return strlen($this->stream); }
    public function url_stat($path) { return strlen($this->stream); }
    }
    stream_wrapper_register('myStream', 'MyStreamWrapper');
    $doc = DOMDocument::load('myStream://foo.xml');
    var_dump($doc);

    Expected result:
    ----------------
    object(DOMDocument)#1 (0) { }

    Actual result:
    --------------
    Warning: DOMDocument::load() [function.DOMDocument-load]: I/O warning :
    failed to load external entity "myStream://foo" in
    DomDocument_load-StreamWrapper.php on line 43

    --
    Edit bug report at [url]http://bugs.php.net/?id=40656&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40656&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40656&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40656&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40656&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40656&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40656&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40656&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40656&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40656&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40656&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40656&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40656&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40656&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40656&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40656&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40656&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40656&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40656&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40656&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40656&r=mysqlcfg[/url]
    bugs at php dot frankkleine dot de Guest

  2. Similar Questions and Discussions

    1. Does FMS support live stream switching
      I read a blog article (http://www.peachpit.com/articles/article.aspx?p=665127) talking about switching between different bit rate video streams of...
    2. #39961 [NEW]: fread() trouble with stream wrappers
      From: php_nospam at ramihyn dot sytes dot net Operating system: Win32,Linux x86 PHP version: 5.2.0 PHP Bug Type: Streams...
    3. #39961 [Opn->Bgs]: fread() trouble with stream wrappers
      ID: 39961 Updated by: tony2001@php.net Reported By: php_nospam at ramihyn dot sytes dot net -Status: Open...
    4. #39823 [NEW]: DOMDocument::load() trims off end of include path
      From: esayre at olemiss dot edu Operating system: Red Hat Enterprise Linux 3 PHP version: 5.2.0 PHP Bug Type: DOM XML related...
    5. stream does not support seeking
      Hello all, Based on some variables I create the path and file name for a file to include. I get the following error: stream does not support...
  3. #2

    Default #40656 [Opn->Bgs]: DOMDocument::load() does not support stream wrappers

    ID: 40656
    Updated by: [email]rrichards@php.net[/email]
    Reported By: bugs at php dot frankkleine dot de
    -Status: Open
    +Status: Bogus
    Bug Type: Feature/Change Request
    Operating System: irrelevant
    PHP Version: 5.2.1
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    url_stat needs to return an array


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-27 10:05:52] bugs at php dot frankkleine dot de

    Description:
    ------------
    The DOMDocument::load() method does not support working with stream
    wrappers. It's an inconsistency within PHP, one would expect that this
    method works with stream wrappers as well just as other methods and
    functions do.

    Reproduce code:
    ---------------
    class MyStreamWrapper
    {
    protected $read = false;
    protected $stream = '<?xml version="1.0"
    encoding="iso-8859-1"?><foo><bar id="1">hello world</bar></foo>';
    public function stream_open($path, $mode, $options, $opened_path)
    {return true; }
    public function stream_close() { }
    public function stream_read($count)
    {
    if (true == $this->read) { return ''; }
    $this->read = true;
    return $this->stream;
    }
    public function stream_eof() { return $this->read; }
    public function stream_stat() { return strlen($this->stream); }
    public function url_stat($path) { return strlen($this->stream); }
    }
    stream_wrapper_register('myStream', 'MyStreamWrapper');
    $doc = DOMDocument::load('myStream://foo.xml');
    var_dump($doc);

    Expected result:
    ----------------
    object(DOMDocument)#1 (0) { }

    Actual result:
    --------------
    Warning: DOMDocument::load() [function.DOMDocument-load]: I/O warning :
    failed to load external entity "myStream://foo" in
    DomDocument_load-StreamWrapper.php on line 43


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40656&edit=1[/url]

    rrichards@php.net Guest

  4. #3

    Default #40656 [Bgs->Opn]: DOMDocument::load() urlencodes parts of an URI

    ID: 40656
    User updated by: bugs at php dot frankkleine dot de
    -Summary: DOMDocument::load() does not support stream wrappers
    Reported By: bugs at php dot frankkleine dot de
    -Status: Bogus
    +Status: Open
    -Bug Type: Feature/Change Request
    +Bug Type: DOM XML related
    Operating System: irrelevant
    PHP Version: 5.2.1
    New Comment:

    Thanks to your reply I found out what the real problem is. The
    DOMDocument::load() urlencodes parts of the URI used for the stream
    wrapper:
    myStream://C:\master\bla.php?foo.xml
    becomes
    myStream://C:%5Cmaster%5Cbla.php?foo.xml"
    To work properly, the stream wrapper class first has to look if the
    $path argument of stream_open() does exist, if not it has to do an
    urldecode() on the $path and then check if the urldecoded $path
    exists. It is my expectation that the stream wrapper should get the
    correct $path from DOMDocument::load(), not an urlencoded one.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-27 11:22:35] [email]rrichards@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    url_stat needs to return an array

    ------------------------------------------------------------------------

    [2007-02-27 10:05:52] bugs at php dot frankkleine dot de

    Description:
    ------------
    The DOMDocument::load() method does not support working with stream
    wrappers. It's an inconsistency within PHP, one would expect that this
    method works with stream wrappers as well just as other methods and
    functions do.

    Reproduce code:
    ---------------
    class MyStreamWrapper
    {
    protected $read = false;
    protected $stream = '<?xml version="1.0"
    encoding="iso-8859-1"?><foo><bar id="1">hello world</bar></foo>';
    public function stream_open($path, $mode, $options, $opened_path)
    {return true; }
    public function stream_close() { }
    public function stream_read($count)
    {
    if (true == $this->read) { return ''; }
    $this->read = true;
    return $this->stream;
    }
    public function stream_eof() { return $this->read; }
    public function stream_stat() { return strlen($this->stream); }
    public function url_stat($path) { return strlen($this->stream); }
    }
    stream_wrapper_register('myStream', 'MyStreamWrapper');
    $doc = DOMDocument::load('myStream://foo.xml');
    var_dump($doc);

    Expected result:
    ----------------
    object(DOMDocument)#1 (0) { }

    Actual result:
    --------------
    Warning: DOMDocument::load() [function.DOMDocument-load]: I/O warning :
    failed to load external entity "myStream://foo" in
    DomDocument_load-StreamWrapper.php on line 43


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40656&edit=1[/url]
    bugs at php dot frankkleine dot de Guest

  5. #4

    Default #40656 [Opn->Bgs]: DOMDocument::load() urlencodes parts of an URI

    ID: 40656
    Updated by: [email]rrichards@php.net[/email]
    Reported By: bugs at php dot frankkleine dot de
    -Status: Open
    +Status: Bogus
    Bug Type: DOM XML related
    Operating System: irrelevant
    PHP Version: 5.2.1
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    You have to use valid URIs (hence the "\" gets encoded).


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-28 14:23:58] bugs at php dot frankkleine dot de

    Thanks to your reply I found out what the real problem is. The
    DOMDocument::load() urlencodes parts of the URI used for the stream
    wrapper:
    myStream://C:\master\bla.php?foo.xml
    becomes
    myStream://C:%5Cmaster%5Cbla.php?foo.xml"
    To work properly, the stream wrapper class first has to look if the
    $path argument of stream_open() does exist, if not it has to do an
    urldecode() on the $path and then check if the urldecoded $path
    exists. It is my expectation that the stream wrapper should get the
    correct $path from DOMDocument::load(), not an urlencoded one.

    ------------------------------------------------------------------------

    [2007-02-27 11:22:35] [email]rrichards@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    url_stat needs to return an array

    ------------------------------------------------------------------------

    [2007-02-27 10:05:52] bugs at php dot frankkleine dot de

    Description:
    ------------
    The DOMDocument::load() method does not support working with stream
    wrappers. It's an inconsistency within PHP, one would expect that this
    method works with stream wrappers as well just as other methods and
    functions do.

    Reproduce code:
    ---------------
    class MyStreamWrapper
    {
    protected $read = false;
    protected $stream = '<?xml version="1.0"
    encoding="iso-8859-1"?><foo><bar id="1">hello world</bar></foo>';
    public function stream_open($path, $mode, $options, $opened_path)
    {return true; }
    public function stream_close() { }
    public function stream_read($count)
    {
    if (true == $this->read) { return ''; }
    $this->read = true;
    return $this->stream;
    }
    public function stream_eof() { return $this->read; }
    public function stream_stat() { return strlen($this->stream); }
    public function url_stat($path) { return strlen($this->stream); }
    }
    stream_wrapper_register('myStream', 'MyStreamWrapper');
    $doc = DOMDocument::load('myStream://foo.xml');
    var_dump($doc);

    Expected result:
    ----------------
    object(DOMDocument)#1 (0) { }

    Actual result:
    --------------
    Warning: DOMDocument::load() [function.DOMDocument-load]: I/O warning :
    failed to load external entity "myStream://foo" in
    DomDocument_load-StreamWrapper.php on line 43


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40656&edit=1[/url]
    rrichards@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139