ID: 37274
Comment by: phpbugs at mike-c dot com
Reported By: tp at synolon dot gr
Status: Open
Bug Type: COM related
Operating System: Windows XP Pro
PHP Version: 5.1.3
New Comment:
I recently started playing around with COM objects in PHP, and this bug
has been causing me a huge headache. I've read several reports,
including one which was marked fixed, so I did some research...
The following syntax works on PHP 5.0.4:
$Obj->Attribute['Name'] = $Val;
However on PHP 5.0.5, it throws an exception:
Fatal error: Uncaught exception 'com_exception' with message 'Error
[0x8002000e] Invalid number of parameters.
This therefore appears to be a regression dating back to apr/may 05.
Previous Comments:
------------------------------------------------------------------------
[2006-05-26 06:40:05] tp at synolon dot gr
For the '$': Sorry, I misstyped it, but only here. In my original code
this is OK. Unfortunately this is not the problem.
I wonder if the problem is that the array style property returns an
object and not a simple data type. When bug 28161 was fixed I saw that
it was related with array style properties that could be assigned a
value directly (eg a string, a number etc). But what about object COM
properties?
------------------------------------------------------------------------
[2006-05-25 14:46:46] dtyschenko at soft-ukraine dot com
$this->kbmDetail->Field[ fieldname ]->Value = $fieldvalue;
Is it okay, that you type filedname without '$' ???
------------------------------------------------------------------------
[2006-05-02 09:59:52] tp at synolon dot gr
Description:
------------
This seems to be related with bug #28161 that, as I read, was fixed
since version 5.0. I want to access an array style COM property that is
actually an object and then get or set a property of that object. I get
a COM exception when I do that followed by apache crash.
I have tried all binary PHP distributions for Windows that I found from
5.1.2 to 5.1.3 (cvs also) and did not work.
My PHP setup is the typical one described in 'install.txt' of the PHP
package. The only change that I have made in php.ini (except of the
doc_root) is 'com.allow_dcom = true'.
I use Apache 1.3.27.
Please help!
Reproduce code:
---------------
public function setField( $fieldname , $fieldvalue , $masterobj = true
)
{
// kbm & kbmDetail are class member variables
// that were previously instanciated like this:
// $this->kbm = new COM( "SasClient.kbm" );
// The kbm object has an array style property
// 'Field' that returns an object. We want to
// set the 'Value' property.
// In VB this code looks like this:
// kbm.Field( fieldname ).Value = fieldvalue
try
{
if( $masterobj )
$this->kbm->Field[ $fieldname ]->Value = $fieldvalue;
else
$this->kbmDetail->Field[ fieldname ]->Value =
$fieldvalue;
}
catch( com_exception $e )
{
print( $e->__toString( ) );
}
}
Expected result:
----------------
The property should be set
Actual result:
--------------
exception 'com_exception' with message 'Error [0x8002000e] Invalid
number of parameters. ' in c:\data\www\senapi\CSen.php:259 Stack trace:
#0 c:\data\www\senapi\CSen.php(259): CSen::setField() #1
c:\data\www\senapi\sentest.php(206): CSen->setField('docid', -1001) #2
{main}docid = -1001
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37274&edit=1