Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62626 invoked from network); 31 Jul 2013 21:58:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2013 21:58:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.44 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.44 mail-la0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:61770] helo=mail-la0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/B6-07795-67889F15 for ; Wed, 31 Jul 2013 17:58:16 -0400 Received: by mail-la0-f44.google.com with SMTP id fo12so916043lab.17 for ; Wed, 31 Jul 2013 14:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=jjxKUTmtIDchojCjJC2nfKW7A/2ZUUOL03DizKvDtUk=; b=qgI7IExh2GAzop4H1wlcE+6nwaQNHoa5U5dg3Hrl3p6B4r/u5qBsTouk3oeVGsFI0Q zlJwGUQOw7AttYXpQVkPAEytWuwWFnClON7cB2xKhEtE3HM1+2TG3emHzB5TU7wgD2Tc QIJs3oFzoLn/on5DBNFKo8Tim7wePMteTakRYUlEHaS9X+NxW9I9vpWqshnk1TcP5Tsl F6TwzFcpBJxG2GmZTig/NK0IOqzToSYk2VOJzE3hrrTkBq2iPz/jWWiT9GeoSs8DEUJt rnHcvKUVaZQJ90gl4EAloH6Q229HpWy2omrp83HokV5IXaf58xPXnKkSXfKoOo3NiU8Z G75Q== X-Received: by 10.152.28.199 with SMTP id d7mr31890178lah.67.1375307891478; Wed, 31 Jul 2013 14:58:11 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.133.201 with HTTP; Wed, 31 Jul 2013 14:57:31 -0700 (PDT) In-Reply-To: References: Date: Thu, 1 Aug 2013 06:57:31 +0900 X-Google-Sender-Auth: fQs2XBmyhX08uCTanxwQ6GLVil8 Message-ID: To: Julien SALLEYRON Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0160b4325415f204e2d5d2eb Subject: Re: [PHP-DEV] zend_execute_ex problem From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e0160b4325415f204e2d5d2eb Content-Type: text/plain; charset=UTF-8 Hi Julien, On Wed, Jul 31, 2013 at 10:05 PM, Julien SALLEYRON < > julien.salleyron@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... > > > > > > > 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 yohgaki@ohgaki.net --089e0160b4325415f204e2d5d2eb--