Moriyoshi Koizumi | 12 Mar 00:54 2005

Re: [PHP-DEV] HALT Patch

Hi,

I modified your patch so it can capture the position where the
supposed data begins into the constant __HALT_PHP_PARSER__.

There may be a problem with my patch if more than one require()'d /
include()'d script contain __HALT_PHP_PARSER__, but it'd be
quite handy if such an issue is resolved.

<?php
$fp = fopen(__FILE__, 'rb');
fseek($fp, __HALT_PHP_PARSER__, SEEK_SET);
fpassthru($fp);
?>
<?php __HALT_PHP_PARSER__; ?>
abc
def

Moriyoshi

Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.124
diff -u -r1.124 zend_language_scanner.l
--- Zend/zend_language_scanner.l	7 Mar 2005 16:48:49 -0000	1.124
+++ Zend/zend_language_scanner.l	11 Mar 2005 23:47:11 -0000
 <at>  <at>  -1342,6 +1342,13  <at>  <at> 
(Continue reading)

Christian Schneider | 12 Mar 12:58 2005

Re: [PHP-DEV] HALT Patch

Moriyoshi Koizumi wrote:
> I modified your patch so it can capture the position where the
> supposed data begins into the constant __HALT_PHP_PARSER__.

Sounds like a good idea to me as all the manual work to guess the start 
of the data look a bit kludgy to me.

> <?php
> $fp = fopen(__FILE__, 'rb');
> fseek($fp, __HALT_PHP_PARSER__, SEEK_SET);
> fpassthru($fp);
> ?>
> <?php __HALT_PHP_PARSER__; ?>
> abc
> def

Hmm.. I was wondering if we should go one step further and also provide 
a stream to the data. If the most common usage of this construct is 
going to be reading the data after __HALT_PHP_PARSER__ then we should 
optimize for that case. Something like

<?php
$data = gzdeflate(file_get_contents("php://data"));
?>
<?php __DATA__; ?>
...

- Chris

--

-- 
(Continue reading)

John Coggeshall | 12 Mar 13:19 2005

Re: [PHP-DEV] HALT Patch

I think the lexer patch is good enough. 

John

On Sat, 2005-03-12 at 06:58, Christian Schneider wrote:
> Moriyoshi Koizumi wrote:
> > I modified your patch so it can capture the position where the
> > supposed data begins into the constant __HALT_PHP_PARSER__.
> 
> Sounds like a good idea to me as all the manual work to guess the start 
> of the data look a bit kludgy to me.
> 
> > <?php
> > $fp = fopen(__FILE__, 'rb');
> > fseek($fp, __HALT_PHP_PARSER__, SEEK_SET);
> > fpassthru($fp);
> > ?>
> > <?php __HALT_PHP_PARSER__; ?>
> > abc
> > def
> 
> Hmm.. I was wondering if we should go one step further and also provide 
> a stream to the data. If the most common usage of this construct is 
> going to be reading the data after __HALT_PHP_PARSER__ then we should 
> optimize for that case. Something like
> 
> <?php
> $data = gzdeflate(file_get_contents("php://data"));
> ?>
> <?php __DATA__; ?>
(Continue reading)

Andi Gutmans | 12 Mar 19:16 2005

Re: [PHP-DEV] HALT Patch

Yeah I would go and over-engineer this patch.
It's not exactly a general purpose patch especially when it comes to web. 
So I think it is already questionable how many ppl would actually use it. 
Taking that an over-engineering it doesn't make sense.

Andi

At 07:19 AM 3/12/2005 -0500, John Coggeshall wrote:
>I think the lexer patch is good enough.
>
>John
>
>On Sat, 2005-03-12 at 06:58, Christian Schneider wrote:
> > Moriyoshi Koizumi wrote:
> > > I modified your patch so it can capture the position where the
> > > supposed data begins into the constant __HALT_PHP_PARSER__.
> >
> > Sounds like a good idea to me as all the manual work to guess the start
> > of the data look a bit kludgy to me.
> >
> > > <?php
> > > $fp = fopen(__FILE__, 'rb');
> > > fseek($fp, __HALT_PHP_PARSER__, SEEK_SET);
> > > fpassthru($fp);
> > > ?>
> > > <?php __HALT_PHP_PARSER__; ?>
> > > abc
> > > def
> >
> > Hmm.. I was wondering if we should go one step further and also provide
(Continue reading)

Christian Schneider | 12 Mar 19:25 2005

Re: [PHP-DEV] HALT Patch

Andi Gutmans wrote:
> Yeah I would go and over-engineer this patch.

I agree with you guys, I was just brain-storming ;-)

> It's not exactly a general purpose patch especially when it comes to 
> web. So I think it is already questionable how many ppl would actually 
> use it. Taking that an over-engineering it doesn't make sense.

Based on that I'm not sure if the minimal patch should go into PHP 
either as it's sort of easing a problem of one single person only. 
Luckily I'm not in the position of having to decide :-)

- Chris

--

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

Ilia Alshanetsky | 12 Mar 19:27 2005

Re: [PHP-DEV] HALT Patch

> Hmm.. I was wondering if we should go one step further and also provide 
> a stream to the data. If the most common usage of this construct is 
> going to be reading the data after __HALT_PHP_PARSER__ then we should 
> optimize for that case. Something like
> 
> <?php
> $data = gzdeflate(file_get_contents("php://data"));
> ?>
> <?php __DATA__; ?>
> ...

I would suggest keeping such implementation in the user-land code rather 
then the core. It would be fairly trivial to implement a streams wrapper 
to do this and it can internally handle various decoding schema like 
decompression etc...

Ilia

--

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

Sara Golemon | 12 Mar 18:26 2005
Picon
Picon

Re: [PHP-DEV] HALT Patch

> Hmm.. I was wondering if we should go one step further and also provide a 
> stream to the data. If the most common usage of this construct is going to 
> be reading the data after __HALT_PHP_PARSER__ then we should optimize for 
> that case. Something like
>
> <?php
> $data = gzdeflate(file_get_contents("php://data"));
> ?>
> <?php __DATA__; ?>
> ...
I think at that point this progresses from "unobtrusive lexer enhancement" 
into the realm of "magic voodoo fluffiness".

--

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

Ilia Alshanetsky | 12 Mar 19:20 2005

Re: [PHP-DEV] HALT Patch

Moriyoshi Koizumi wrote:
> Hi,
> 
> I modified your patch so it can capture the position where the
> supposed data begins into the constant __HALT_PHP_PARSER__.
> 
> There may be a problem with my patch if more than one require()'d /
> include()'d script contain __HALT_PHP_PARSER__, but it'd be
> quite handy if such an issue is resolved.

+1 seems like a good idea.

Ilia

--

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


Gmane