Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27659 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68605 invoked by uid 1010); 25 Jan 2007 17:11:12 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68590 invoked from network); 25 Jan 2007 17:11:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2007 17:11:12 -0000 Authentication-Results: pb1.pair.com header.from=frank@kromann.info; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=frank@kromann.info; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain kromann.info designates 64.186.239.125 as permitted sender) X-PHP-List-Original-Sender: frank@kromann.info X-Host-Fingerprint: 64.186.239.125 c-064-186-239-125.oc1.redwire.net Linux 2.5 (sometimes 2.4) (4) Received: from [64.186.239.125] ([64.186.239.125:53809] helo=mail.kromann.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/E3-13597-EA4E8B54 for ; Thu, 25 Jan 2007 12:11:11 -0500 Received: by mail.kromann.info (Postfix, from userid 510) id 204CD4040CB; Thu, 25 Jan 2007 09:11:08 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on mail.kromann.info X-Spam-Level: X-Spam-Status: No, score=0.7 required=4.0 tests=AWL autolearn=ham version=3.1.7 Received: from warp (www.kromann.info [64.186.239.115]) by mail.kromann.info (Postfix) with SMTP id 487E64040C9; Thu, 25 Jan 2007 09:11:07 -0800 (PST) To: Andy Wharmby Cc: PHP internals list , Wez Furlong X-Mailer: Swwwing 2000 Message-ID: <11697450594440000@9866357972520000.9866341568840000> MIME-Version: 1.0 Reply-To: "Frank M. Kromann" Date: Thu, 25 Jan 2007 09:10:59 -0800 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] COM extension defects: Possible patch for defect 35464 From: frank@kromann.info ("Frank M. Kromann") Hi Andy, I think this code and your explanations look good. I'll give the patch a run tonight when I get home but I do not see any problems with it. - Frank > Hi Internals > Attached is a suggested patch for COM defect 35464 > (http://bugs.php.net/bug.php?id=34564) Any comments; good or bad welcome. > Regards > Andy > > Andy Wharmby > IBM United Kingdom Limited > Winchester, England SO21 2JN > E-mail: andy_wharmby@uk.ibm.com > > COM defect 35464 > ================ > > The following details 2 reasons why in/out parameters don't work; one > caused by a problem with tetscase another a defect in COM extension code. > The testcase supplied by the raiser implements the DWebBrowserEvents2 > interface to register an handler for the BeforeNaviagte2 event. This > handler is passed just one in/out parameter; a VARIANT_BOOL which can > be set to TRUE by the handler to cancel the navigation operation. > Doing so in PHP currently has no affect, for the 2 reasons I will > describe below, so the navigation completes and the specified page is > displayed by IE. > > Issue 1 > ====== > The users code is attempting to modify the variant directly in PHP code > as follows: > > $cancel = true; > > rather than using the COM method variant_set as follows: > > variant_set($cancel, true); > > With this correction to the PHP script in place the variant for $cancel > is correctly changed to TRUE but IE still navigates to the requested page > so the modification is having no effect. The reason for this is the > subject of issue 2 below. > > Issue 2 > ====== > When an event notification is received by the COM extension > disp_invokeex() processes the incoming parameters (variants) by taking > each one > and wrapping it in a php_com_dotnet_object object. At this time a COPY > of the incoming variant is embedded into the php_com_dotnet_object so we > immediately have 2 copies of the variant and it is this copy in the > php_com_dotnet_object which is processed (get and set) by the PHP code. > I see no code that checks for modification to our copy in the > php_com_dotnet_object before returning to the caller (in this case IE) > so modification > to in/out parameters by the PHP code has no affect. > > Given that the code copies an incoming variant in php_com_wrap_variant() > I would have expected to see some code prior to return in disp_invokeex() > which checks for modifications to in/out parameters and copies any > modified values back to the callers copy of the variant. > > I have hacked some code as follows: > com_wrapper.c: http://www.pastebin.ca/328026 > com_variant.c: http://www.pastebin.ca/328022 > com_misc.c: http://www.pastebin.ca/328025 > php_com_dotnet_internal.h: http://www.pastebin.ca/328027 > > The new code works as follows: > (1) When a variant is modified by a call to variant_set() in > com_variant.c a new flag (obj->modified) is set in the > php_com_dotnet_object. > > (2) After a successful call to a event handler new code in > com_wrapper.c function disp_invokeex() checks each of the event > handlers arguments > (php_com_dotnet_object's ) to see if any of their embedded variants > have been modified. If so and the argument passed into the event handler was > passed by reference then the value in the embedded variant is copied to > the callers copy by a call to a new function php_com_copy_variant() > defined in com_variant.c. > > With this patch applied when the supplied testcase is run the navigation > is now cancelled as expected. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >