php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42929 Cannot access the old stream wrapper from a wrapper class
Submitted: 2007-10-11 14:24 UTC Modified: 2011-04-08 21:15 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: woodsmailbox at yahoo dot com Assigned:
Status: Open Package: Streams related
PHP Version: 5.2.4 OS: WinXP SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-10-11 14:24 UTC] woodsmailbox at yahoo dot com
Description:
------------
I would like to "wrap" a stream wrapper, and this would include calling the original wrapper's methods from my wrapper class. For instance, I would like to implement versioning over the file:// protocol but I cannot access the filesystem while my file:// wrapper is registered. It would be nice to be able to use the classes of built-in wrappers.

Also, I can't find the php function to change the default wrapper so I can have relative paths handled by my wrapper. A lot of app. code not under my control use relative paths. I could register my own file:// wrapper but then again...

My current workaround is to call stream_wrapper_restore() inside my wrapper's functions, do my thing with the filesystem, then call stream_wrapper_register() again, but I think this sucks. I hope php is doing no more than changing some pointers internally when I call these functions, otherwise, the performance of my wrapper is gone.

Thanx.
Cosmin.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-11 14:52 UTC] woodsmailbox at yahoo dot com
... Another feature that could get me out of this chicken and egg problem would be to be able to alias a built-in wrapper protocol in its current configuration (i.e. with it's current handler class). I would happily alias "file:" to "filesystem:" and then register my own wrapper class to the "file:" protocol and use the "filesystem:" protocol internally.
 [2007-10-12 14:48 UTC] woodsmailbox at yahoo dot com
I also think getcwd() and chdir() should be open for stream-wrapping for  the relative paths to work with a wrapper for the default "file" scheme.
 [2011-04-08 21:15 UTC] jani@php.net
-Package: Feature/Change Request +Package: Streams related
 [2014-04-11 22:35 UTC] neufeind@php.net
Only way around this seems to be to inside your wrapper-function then to call stream_wrapper_restore(), perform the work on your regular filesystem and before the end re-register your stream-wrapper. While it's sort of a "hack" this way we successfully created a wrapper that overlays certain directories/files but passes through all others to the real file-layer.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC