Re: REMINDER - stream wrappers in include_path
| From: | Gregory Beaver | Date: | Mon, 24 Mar 2008 14:41:32 +0000 |
| Subject: | Re: REMINDER - stream wrappers in include_path | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-36431@lists.php.net to get a copy of this message | ||
Dmitry Stogov wrote:
> REALPATH_FAILED looks like a hack :(
> PHP itself doesn't need it at all, according to your patch
> php_stream_open() may just return NULL immediately instead of setting
> of this flag.
> However I am not sure that it will work for all cases. The fact that
> we cannot resolve the path doesn't mean that we cannot open the file.
> (On some systems getcwd() may fail on some reasons).
I remember Solaris having issues with this, now that you mention it.
However, the place that I added this already returned NULL if realpath
fails, it doesn't change the behavior, just moves the realpath to an
earlier position and eliminates an unnecessary double call. However, if
we are comfortable having the double realpath on files not found in
include_path (this would only have a performance affect on apps with
lots of conditional loading of drivers where the majority are not
found), this is fine with me. I've attached a patch that removes
REALPATH_FAILED so there are options.
Another option would be to determine which OSes this can fail, and
simply not use REALPATH_FAILED on those OSes.
> I didn't test the patch with pecl/phar.
> Could you explain why php goes into the endless loop?
because the cut/paste to plain_wrapper.c:1419 needs a ptr = end, unlike
the code in fopen_wrappers.c. Once you fix this problem, then the real
logic problem rears its head, which is that we go into plain_wrapper to
open an external stream wrapper. It is far less efficient (about 4-6%
by my measurements) to do this, which is why I moved the include_path
parsing into streams.c
This bug only happens when the last item in include_path is a stream
wrapper and the file is not found in include_path.
Greg