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] alternative to the fopen() hack in autoloaders

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 22:28, Stanislav Malyshev wrote: Hi! They dont want to determine if a file exists. They want to be able to handle the case of a missing file being included differently than a syntax error. Since php core does not provide such features, the only Let's see why they need

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

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 22:41, Alban wrote: I think if PHP throws exception instead of warning/error then this problem will not have existence reason : sure with exceptions we could provide more contextual information and also give a local way to handle the situation locally. that being said f

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

2009-11-10 Thread Alban
Le Tue, 10 Nov 2009 21:56:47 +0100, Lukas Kahwe Smith a écrit : > On 10.11.2009, at 21:31, Stanislav Malyshev wrote: > >>> ok .. so your objection to the RFC is solely because it introduces a >>> new language construct? >> >> No, my objection is that it is not necessary to introduce a language >>

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

2009-11-10 Thread Stanislav Malyshev
Hi! They dont want to determine if a file exists. They want to be able to handle the case of a missing file being included differently than a syntax error. Since php core does not provide such features, the only Let's see why they need to handle missing file being included differently? Or,

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

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 21:31, Stanislav Malyshev wrote: ok .. so your objection to the RFC is solely because it introduces a new language construct? No, my objection is that it is not necessary to introduce a language construct, and the construct introduced is not the right one. If frameworks

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

2009-11-10 Thread Stanislav Malyshev
Hi! ok .. so your objection to the RFC is solely because it introduces a new language construct? No, my objection is that it is not necessary to introduce a language construct, and the construct introduced is not the right one. If frameworks want to find out if file exists or get its name -

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] alternative to the fopen() hack in autoloaders

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 20:38, Stanislav Malyshev wrote: there are many approaches to caching, one of which is delete to invalidate and regenerate before the next use. again as the RFC makes it clear .. the purpose is to be able to differentiate between a syntax error and a missing file. If yo

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

2009-11-10 Thread Stanislav Malyshev
Hi! there are many approaches to caching, one of which is delete to invalidate and regenerate before the next use. again as the RFC makes it clear .. the purpose is to be able to differentiate between a syntax error and a missing file. If you writing your own cache basing on includes, you ca

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

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 20:07, Stanislav Malyshev wrote: Hi! yes that would solve the issue partially. the race condition would still remain, but its admitedly a rare case .. well I guess not so rare if you I would have hard time thinking of application that deletes its own include files fre

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

2009-11-10 Thread Stanislav Malyshev
Hi! yes that would solve the issue partially. the race condition would still remain, but its admitedly a rare case .. well I guess not so rare if you I would have hard time thinking of application that deletes its own include files frequently from other processes and we are supposed to hand

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

2009-11-10 Thread Lukas Kahwe Smith
On 10.11.2009, at 19:49, Stanislav Malyshev wrote: Hi! In order to solve the above issues this RFC proposes the addition of a new construct/function for now called “autoload_include” for lack of a better name that largely behaves like the “include” does today with the following differenc

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

2009-11-10 Thread Stanislav Malyshev
Hi! In order to solve the above issues this RFC proposes the addition of a new construct/function for now called “autoload_include” for lack of a better name that largely behaves like the “include” does today with the following differences, that when the include failed because of a missing file

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

2009-11-10 Thread Igor Feghali
> As stated in the RFC, I am not happy with the name "autoload_include". > Suggestions welcome! That reminds me of the set theory... how about: contain $file; or superset $file; there are also the not so original (as found in many other languages) keywords "import" / "load". Best, ~IF. -- PH

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] Regarding constructions like func()[0]

2009-11-10 Thread Stanislav Malyshev
Hi! Whilst you are all thinking about this, how about ... $value = (function(){return $x;})(); I tried implementing that but it's not straightforward because you need to keep the result of first call while everything inside () is calculated (which can be any number of expressions including

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

Re: [PHP-DEV] About php6 gc

2009-11-10 Thread Derick Rethans
On Tue, 10 Nov 2009, Mathieu Suen wrote: > By looking at the php6 gc I guess you introduce a mark and sweep gc. > Looking at the *_root function, it also seems that you have a generational > mark & sweep gc. > > I have a couple of question : > > How many generation do you have? > > What is the

[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

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

2009-11-10 Thread Guilherme Blanco
include_silent is the name I though most intuitive once I finished to read the RFC. But it may not be the best too. It just need to be verbose. Cheers, On Tue, Nov 10, 2009 at 2:45 PM, Lukas Kahwe Smith wrote: > Ahoi, > > I have written an RFC for a more efficient solution to get rid of the com

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

2009-11-10 Thread Lukas Kahwe Smith
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 proposes the addition of a ne

Re: [PHP-DEV] No core file being created

2009-11-10 Thread Mark Skilbeck
Scott MacVicar wrote: On 10 Nov 2009, at 13:55, Mark Skilbeck wrote: I'm trying to debug a segfault that's occuring in an extension I'm developing (phpgksu - PHP wrapper for libgksu2). On the PHP site it says that if I have PHP configured with --enable-debug (which I do) then whenever PHP cra

Re: [PHP-DEV] No core file being created

2009-11-10 Thread Antony Dovgal
On 10.11.2009 16:55, Mark Skilbeck wrote: > I'm trying to debug a segfault that's occuring in an extension I'm > developing (phpgksu - PHP wrapper for libgksu2). On the PHP site it says > that if I have PHP configured with --enable-debug (which I do) then > whenever PHP crashes a core file shoul

Re: [PHP-DEV] No core file being created

2009-11-10 Thread Scott MacVicar
On 10 Nov 2009, at 13:55, Mark Skilbeck wrote: I'm trying to debug a segfault that's occuring in an extension I'm developing (phpgksu - PHP wrapper for libgksu2). On the PHP site it says that if I have PHP configured with --enable-debug (which I do) then whenever PHP crashes a core file sho

[PHP-DEV] No core file being created

2009-11-10 Thread Mark Skilbeck
I'm trying to debug a segfault that's occuring in an extension I'm developing (phpgksu - PHP wrapper for libgksu2). On the PHP site it says that if I have PHP configured with --enable-debug (which I do) then whenever PHP crashes a core file should be created in the same directory the file is ex

Re: [PHP-DEV] Regarding constructions like func()[0]

2009-11-10 Thread Mathieu Suen
jvlad a écrit : "Mathieu Suen" wrote in message news:4af91f92.4000...@easyflirt.com... Why isn't a mater of pushing the function call statement into a valuable statement? I guess something like this: statement : | value | function_call; value : | valriable | array_access | method_send | ..

Re: [PHP-DEV] Regarding constructions like func()[0]

2009-11-10 Thread jvlad
"Mathieu Suen" wrote in message news:4af91f92.4000...@easyflirt.com... > > Why isn't a mater of pushing the function call statement into a valuable > statement? > > I guess something like this: > > statement : > | value > | function_call; > > > value : > | valriable > | array_access > | method_s

[PHP-DEV] About php6 gc

2009-11-10 Thread Mathieu Suen
Hi, By looking at the php6 gc I guess you introduce a mark and sweep gc. Looking at the *_root function, it also seems that you have a generational mark & sweep gc. I have a couple of question : How many generation do you have? What is the meaning of the different color (black, white, grey)

Re: [PHP-DEV] Regarding constructions like func()[0]

2009-11-10 Thread Mathieu Suen
melfar a écrit : Hey, Yep, I think there might be some caveats to that change. The original patch did not work on methods, so I've fixed that and also made the return value an rvalue, so that you can't attempt to modify the temporary value, the zend_check_writable_variable guard will yield an er