Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2010-01-06 Thread Lukas Kahwe Smith
On 29.12.2009, at 00:25, Ralph Schindler wrote: > Bump. > > I really think we need to think about this problem that Lukas has brought up. > > Now that the magic words have come up ('counting stat calls'), can we get > someone to weight in on the possibility of both having some kind of > inclu

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-12-28 Thread Ralph Schindler
Bump. I really think we need to think about this problem that Lukas has brought up. Now that the magic words have come up ('counting stat calls'), can we get someone to weight in on the possibility of both having some kind of include_path resolver in the 5.3 branch, and it's impact of stat c

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-12-23 Thread Mikko Koppanen
On Wed, Dec 9, 2009 at 2:04 AM, Stanislav Malyshev wrote: > Hi! > > I think stream_resolve_include_path() should be changed to work through > zend_resolve_path, in any case. Also, what is the reason it can't be in 5.3 > too? > I'd like to both fix stream_resolve_include_path() and get it into 5.3,

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-12-08 Thread Stanislav Malyshev
Hi! I think stream_resolve_include_path() should be changed to work through zend_resolve_path, in any case. Also, what is the reason it can't be in 5.3 too? I'd like to both fix stream_resolve_include_path() and get it into 5.3, any objections to that? If that was done, only problem with usi

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-12-07 Thread Lukas Kahwe Smith
On 22.11.2009, at 18:01, Lukas Kahwe Smith wrote: > I have updated the current RFC accordingly: > http://wiki.php.net/rfc/autoload_include > > So there are three approaches listed in the RFC: > 1) http://wiki.php.net/rfc/autoload_include#proposal > add a new alternative to include, which works t

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-22 Thread Greg Beaver
Lukas Kahwe Smith wrote: > Finally optionally include in your vote if would like to see this feature > added to 5.3.2 or if it should wait for the next minor/major version update > instead. +0 on version to include this in, sorry I forgot to include that in my vote. Greg -- PHP Internals - PH

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-22 Thread Greg Beaver
Lukas Kahwe Smith wrote: > So there are three approaches listed in the RFC: > 1) http://wiki.php.net/rfc/autoload_include#proposal > add a new alternative to include, which works the same except that for > missing files it returns null and on success it returns the file location > (unless the fil

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-22 Thread Lukas Kahwe Smith
On 22.11.2009, at 18:01, Lukas Kahwe Smith wrote: > So there are three approaches listed in the RFC: > 1) http://wiki.php.net/rfc/autoload_include#proposal > add a new alternative to include, which works the same except that for > missing files it returns null and on success it returns the file

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-22 Thread Lukas Kahwe Smith
On 11.11.2009, at 14:50, Greg Beaver wrote: > stream_resolve_include_path() as currently constructed could not be > intercepted, and is actually unable to process an include_path that > contains streams. I'm guessing it was written long before PHP 5.3. > This could be easily fixed by having str

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-12 Thread Ralph Schindler
IIRC, Sara created this as a proof of concept to a reoccurring question of why filesystem functions don't have an include include_path argument. Many members argued (and for good merit), that any fs operations should not include the include_path. It was put into trunk and forgotten about, but

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Stanislav Malyshev
Hi! Isn't this what stream_resolve_include_path does? I wasn't even aware it was there (it being undocumented doesn't help a lot). And it is listed as PHP 6 only. I guess if we fix it to work correctly and backport to 5.3 (or even 5.2?) it may just work for frameworks. -- Stanislav Malyshe

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Lukas Kahwe Smith
On 11.11.2009, at 14:50, Greg Beaver wrote: Lukas Kahwe Smith wrote: On 11.11.2009, at 11:44, Mikko Koppanen wrote: On Wed, Nov 11, 2009 at 10:00 AM, Lukas Kahwe Smith so a byte code cache should cache the resolution of the path thereby speeding up the subsequent call to include? strea

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Greg Beaver
Lukas Kahwe Smith wrote: > > On 11.11.2009, at 11:44, Mikko Koppanen wrote: > >> On Wed, Nov 11, 2009 at 10:00 AM, Lukas Kahwe Smith >> wrote: >>> >>> On 11.11.2009, at 01:50, Greg Beaver wrote: >>> if (can_include($file)) { include $file; } >>> >>> >>> I am sure you focused on th

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Lukas Kahwe Smith
On 11.11.2009, at 11:44, Mikko Koppanen wrote: On Wed, Nov 11, 2009 at 10:00 AM, Lukas Kahwe Smith > wrote: On 11.11.2009, at 01:50, Greg Beaver wrote: if (can_include($file)) { include $file; } I am sure you focused on the technical aspects. Just wanted to say that for a name "can" i

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Mikko Koppanen
On Wed, Nov 11, 2009 at 10:00 AM, Lukas Kahwe Smith wrote: > > On 11.11.2009, at 01:50, Greg Beaver wrote: > >> if (can_include($file)) { >>   include $file; >> } > > > I am sure you focused on the technical aspects. Just wanted to say that for > a name "can" is not ideal, because there is no gura

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Lukas Kahwe Smith
On 11.11.2009, at 01:50, Greg Beaver wrote: if (can_include($file)) { include $file; } I am sure you focused on the technical aspects. Just wanted to say that for a name "can" is not ideal, because there is no gurantee that the file will not have syntax errors. As such something with

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Lukas Kahwe Smith
On 11.11.2009, at 10:47, Richard Quadling wrote: 2009/11/11 Lukas Kahwe Smith : [snip] Would using a userland-based set_error_handler() be of use here? If, under normal circumstances, blind include() is what is used, then trapping the error when it fails would be when you could test for wha

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-11 Thread Richard Quadling
2009/11/11 Lukas Kahwe Smith : > [snip] Would using a userland-based set_error_handler() be of use here? If, under normal circumstances, blind include() is what is used, then trapping the error when it fails would be when you could test for whatever it is you want to test for? Richard. -- --

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Lukas Kahwe Smith
Perhaps better would be to introduce a function: if (can_include($file)) { include $file; } opcode caches could easily snag this, as we could provide a simple hook the way we do with stream_resolve_path(). That would actually make a 0-stat smart autoloader a possibility. Just in case i

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Stanislav Malyshev
Hi! Yes, but let's not forget we're talking about making this: While with proper caching, it can be 0 filesystem accesses. if (can_include($file)) { include $file; } That's exactly what I was proposing - to have function to find file in include path and probably return the resulting f

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Greg Beaver
Stanislav Malyshev wrote: > Hi! > >> A good point. Fortunately, most streams do store the filename in the >> stream struct, so this would still probably be possible in the majority >> of cases. If not available, the original requested filename is used >> (the one from the fopen call), so opcode c

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Stanislav Malyshev
Hi! A good point. Fortunately, most streams do store the filename in the stream struct, so this would still probably be possible in the majority of cases. If not available, the original requested filename is used (the one from the fopen call), so opcode caches probably could just use that. T

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Greg Beaver
Stanislav Malyshev wrote: > Hi! > >>> This would break security distinction between file ops and include ops, >>> when URLs are allowed for open but not include. > > Additional thing - it probably would be a problem for bytecode caches, > since they'd have to: > a. watch all file opens, in case som

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Stanislav Malyshev
Hi! This would break security distinction between file ops and include ops, when URLs are allowed for open but not include. Additional thing - it probably would be a problem for bytecode caches, since they'd have to: a. watch all file opens, in case some of these will later be used for inclu

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Greg Beaver
Stanislav Malyshev wrote: > Hi! > >> Alternatively include() could be extended to allow resources, so the >> above would turn info >> >> if ($fp = @fopen($file, 'r', true)) { >> include($fp); >> fclose($fp); >> } > > This would break security distinction between file ops and include ops,

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Rasmus Lerdorf
Stanislav Malyshev wrote: > Hi! > >> Alternatively include() could be extended to allow resources, so the >> above would turn info >> >> if ($fp = @fopen($file, 'r', true)) { >> include($fp); >> fclose($fp); >> } > > This would break security distinction between file ops and include ops,

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Stanislav Malyshev
Hi! Alternatively include() could be extended to allow resources, so the above would turn info if ($fp = @fopen($file, 'r', true)) { include($fp); fclose($fp); } This would break security distinction between file ops and include ops, when URLs are allowed for open but not inc

Re: [PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 18:40, Mark Skilbeck wrote: What's the problem with file_exists() ? i have explained this in the RFC. for one it does not support the include path setting. furthermore this does not solve the race condition and requires more FS operations than my proposal would. regar

[PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Mark Skilbeck
Lukas Kahwe Smith wrote: Ahoi, I have written an RFC for a more efficient solution to get rid of the common fopen() hack inside autoloaders: if ($fp = @fopen($file, 'r', true)) { fclose($fp); include $file; } Here is the gist of the proposal: In order to solve the above issues this RFC propos

[PHP-DEV] Re: alternative to the fopen() hack in autoloaders

2009-11-10 Thread Christian Schneider
Lukas Kahwe Smith wrote: > I have written an RFC for a more efficient solution to get rid of the > common fopen() hack inside autoloaders: > if ($fp = @fopen($file, 'r', true)) { > fclose($fp); > include $file; > } > > Here is the gist of the proposal: > In order to solve the above issues this RFC