On Fri, 04 Mar 2011 01:26:20 -0000, Stas Malyshev <smalys...@sugarcrm.com> wrote:

I try to do some complex code with custom streams and I have discovered the following problem:

The code in main/streams/cast.c, specifically _php_stream_cast, creates fopencookie() synthetic stream for streams that are not actual file streams. Which works fine until such stream is used in include(), in which case it ultimately arrives at zend_stream_fixup(). Which would in turn call zend_stream_fsize() - which would do fstat(fileno(file_handle->handle.fp), &buf) - and that would fail since you can't get fileno for FILE* created by fopencookie. Which ultimately means I can't use my custom streams for include(), which is bad. Now, looking at the code, it doesn't actually need the exact size - http streams can be included just fine - but insists on having it if it has fp (which it can have for basically any kind of stream due to the cookie trick). Does anyone has any idea why and if it can be fixed?

Can you tell what exactly you're doing? Why is there any cast in the first place?

As far as I can see, the include should eventually call php_stream_open_for_zend_ex, which should give a ZEND_HANDLE_STREAM file handle that defers reading to _php_stream_read and fsize to php_zend_stream_fsizer, with no casting involved.

--
Gustavo Lopes

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to