Hi Julien,

On Wed, Jul 31, 2013 at 10:05 PM, Julien SALLEYRON <
> julien.salley...@gmail.com> wrote:
> >
> > The problem here is that I have came to the conclusion (wrong conclusion
> ?) that I need to update the EG(current_execute_data) "as if" the former
> called function had been processed, to actually skip the function that was
> called in PHP.
> >
>

I guess I understand what you would like to to. I might be wrong, though.


> >
> > Maybe some code will be more explicit...
> >
> > <?php
> >
> > myFunction(); //the function is expected to be called (and will)
> >
> >
> > $hook = function () {throw new Exception()};
> >
> > aop_add_before('myFunction()', $hook); //now we ask the extension to
> call hook() before myFunction()
> >
> > myFunction();//Now myFunction should never be called, as the hook is
> raising an exception
> >
> >
> > Extension-wise, the code is located here (
> https://github.com/AOP-PHP/AOP/blob/php5-5/aop.c#L390), where I test if
> the hook raised an exception or not.
> >
> > If it did not, I'm calling the function (
> https://github.com/AOP-PHP/AOP/blob/php5-5/aop.c#L392) and it ends up
> updating EG(current_execute_data) with
> EG(current_execute_data)->prev_execute_data.
> >
> > Now, when the hook is raising an exception, I'd like to just skip the
> function call. If I just "return" (
> https://github.com/AOP-PHP/AOP/blob/php5-5/aop.c#L397) it ends up in an
> infinite loop. reason why I tried  EG (current_execute_data) =
> EG(current_execute_data)->prev_execute_data;
> >
> > But this solution ends up in memory headakes..


Unless you clean up EG(current_execute_data) by yourself, I suppose you'll
have memory issues.

If you would like to skip function to be executed, all you have to do is
"do not call zend_execute()/zend_execute_ex()" when the function is called.

> $hook = function () {throw new Exception()};

Since your code raise exception, you don't have to skip myfunction(). Just
let PHP die with unhandled exception.

It would be easier if you keep functions in hash to determine hooked one
and call hook as needed/skip function as needed. I might not understand
what you really would like to do, but hope this comment helps.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to