#31040 [Fbk->Opn]: Bad parameters when getting some events from browser
| From: | jeanpierre dot vincent at gmail dot com | Date: | Thu, 03 Mar 2005 12:52:31 +0000 |
| Subject: | #31040 [Fbk->Opn]: Bad parameters when getting some events from browser | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74789@lists.php.net to get a copy of this message | ||
ID: 31040
User updated by: jeanpierre dot vincent at gmail dot com
Reported By: jeanpierre dot vincent at gmail dot com
-Status: Feedback
+Status: Open
Bug Type: COM related
Operating System: W2K WinXP
PHP Version: 5.0.2
Assigned To: wez
New Comment:
thanks for solving this bug in your latest release.
now we are actually working on software based on com technology and we
are blocked by this another bug :
http://bugs.php.net/bug.php?id=32170.
Previous Comments:
------------------------------------------------------------------------
[2005-02-28 21:18:14] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-12-13 11:52:10] jeanpierre dot vincent at gmail dot com
this bug exists for all objects events sink.
Problem is in the function disp_invokeex() in file com_wrapper.c
the var zarg declared in the for loop to catch parameters is overwriten
every time, so all parameters have the value of the last one.
The reason why it happened on some functions and not another depends of
the compilation. We had here a random bug !!
the solution is to replace this code (in disp_invokeex() in file
com_wrapper.c)
///////////////////////////bugged code/////////////////////
params = (zval ***)safe_emalloc(sizeof(zval **), pdp->cArgs, 0);
for (i = 0; i < pdp->cArgs; i++) {
VARIANT *arg;
zval *zarg;
arg = &pdp->rgvarg[ pdp->cArgs - 1 - i];
trace("alloc zval for arg %d VT=%08x\n", i,
V_VT(arg));
ALLOC_INIT_ZVAL(zarg[i]);
php_com_wrap_variant(zarg, arg, COMG(code_page)
TSRMLS_CC);
params[i] = &zarg;
}
///////////////////////////////////////////////////////
by this one :
////////////////////correct code/////////////////////
params = (zval ***)safe_emalloc(sizeof(zval **), pdp->cArgs, 0);
for (i = 0; i < pdp->cArgs; i++) {
VARIANT *arg;
zval **zarg= NULL;
zarg=(zval **)safe_emalloc(sizeof(zval *),
pdp->cArgs, 0);
arg = &pdp->rgvarg[ pdp->cArgs - 1 - i];
trace("alloc zval for arg %d VT=%08x\n", i,
V_VT(arg));
ALLOC_INIT_ZVAL(zarg[i]);
php_com_wrap_variant(zarg[i], arg,
COMG(code_page) TSRMLS_CC);
params[i] = &zarg[i];
}
/////////////////////////////////////////////////////////
Hope you'll correct for the next version !
------------------------------------------------------------------------
[2004-12-09 18:24:39] jeanpierre dot vincent at gmail dot com
Description:
------------
For some events of the IE browser, parameters given take value 0 and
are of boolean type.
For example : BeforeNavigate2, BeforeNavigate and CommandStateChange,
whereas events like DocumentComplete work fine.
Here is the example code from http://www.php.net/com-event-sink, which
I simply added BeforeNavigate2. Launch it from a browser or CLI.
Reproduce code:
---------------
class IEEventSinker {
var $terminated = false;
// just after Browser understands he has to navigate
function BeforeNavigate2(&$pDisp, &$url, &$Flags, &$TargetFrameName,
&$PostData, &$Headers, &$Cancel) {
foreach(func_get_args() as $id => $valeur) {
// if the problem occurs ...
if($valeur == 0)
print $id.' = '.$valeur.' of type
'.variant_get_type($valeur)."\n";
}
// if the problem doesnt, $url is filled
if($url != 0)
echo "you'll navigate on $url\n";
}
// when all objects of page are loaded
function DocumentComplete(&$dom, $url) {
echo "Document $url complete\n";
}
// when closing browser
function OnQuit() {
echo "Quit!\n";
$this->terminated = true;
}
}
$ie = new COM("InternetExplorer.Application");
// note that you don't need the & for PHP 5!
$sink = new IEEventSinker();
com_event_sink($ie, $sink, "DWebBrowserEvents2");
$ie->Visible = true;
$ie->Navigate("http://www.php.net");
while(!$sink->terminated) {
com_message_pump(4000);
}
$ie = null;
Expected result:
----------------
you'll navigate on http://www.php.net/
Document http://www.php.net/ complete
Quit!
Actual result:
--------------
0 = 0 of type 11
1 = 0 of type 11
2 = 0 of type 11
3 = 0 of type 11
4 = 0 of type 11
5 = 0 of type 11
6 = 0 of type 11
Document http://www.php.net/ complete
Quit!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31040&edit=1