php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37274 Array style COM property access
Submitted: 2006-05-02 09:59 UTC Modified: 2007-01-01 01:00 UTC
Votes:13
Avg. Score:4.5 ± 0.8
Reproduced:9 of 10 (90.0%)
Same Version:0 (0.0%)
Same OS:5 (55.6%)
From: tp at synolon dot gr Assigned:
Status: No Feedback Package: COM related
PHP Version: 5.1.3 OS: Windows XP Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tp at synolon dot gr
New email:
PHP Version: OS:

 

 [2006-05-02 09:59 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-25 14:46 UTC] dtyschenko at soft-ukraine dot com
$this->kbmDetail->Field[ fieldname ]->Value = $fieldvalue;

Is it okay, that you type filedname without '$' ???
 [2006-05-26 06:40 UTC] 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-08-17 18:30 UTC] phpbugs at mike-c dot com
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.
 [2006-08-18 08:44 UTC] tp at synolon dot gr
I'm happy to see that at least there are others interested in COM communication through PHP. I think that more work has to be done for this module cause brings a bridge for the open source community to the windoze world (it is usefull for some bussiness apps...). For example I could manage to run the code I presented through java using IBM COM bridge and worked OK. But is a pity to run a jsp site just because the COM PHP implemntation is buggy. Also I find it TOO much (in this case...) to call java code through PHP to get this job done... not to mention that my service provider won't support the php to java bridge. We love PHP so please give a look at that bug!
 [2006-12-14 20:47 UTC] lee at dark-circuit dot com
Bug still exists in 5.2.0   :(   I have confirmed the bug is in both 5.1.3 and 5.2.0
 [2006-12-24 12:37 UTC] rrichards@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-01-01 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-01-05 17:08 UTC] phpbugs at mike-c dot com
Still the same error using latest CVS snapshot
(PHP 5.2.1RC3-dev (cli) (built: Jan  5 2007 16:24:22))

PHP Fatal error:  Uncaught exception 'com_exception' with message 'Error [0x8002000e] Invalid number of parameters.' in C:\PHP Files\comobjecttest.php:4
Stack trace:
#0 C:\PHP Files\comobjecttest.php(4): unknown()
#1 {main}
  thrown in C:\PHP Files\comobjecttest.php on line 4
 [2007-02-10 00:08 UTC] lee at dark-circuit dot com
On current snap of PHP 5.2.2 It still doesn't work, but I get a slightly diff trace than some are reporting. Here's mine:

PHP Fatal error:  Uncaught exception 'com_exception' with message
'Error [0x8002000f] Parameter not optional.
' in C:\New Folder\prime-sync-itemdb.php:197
Stack trace:
#0 C:\New Folder\prime-sync-itemdb.php(197): unknown()
#1 {main}
  thrown in C:\New Folder (3)\prime-sync-itemdb.php on line 197

That is on this test line:
$oInfo->CustomField[1] = "bb";

Com property is 
string CustomField(ByVal Index As Integer)

VB.NET Code that works:
oCompanyInfo.CustomField(1) = "bb"

Note: in php: echo $oInfo->CustomField[1]; works fine. I just can't assign anything with an array
 [2007-12-11 14:34 UTC] mjscod at web dot de
I can confirm this behaviour. PHP 5.2.4 contains this bug too.
 [2010-07-06 17:32 UTC] juliec at computersecurity dot com
I can confirm this is an issue with the latest 5.3.2 build also. 

The error is Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000f] Parameter not optional. ' 

Someone created a very simple standalone test library specifically to reproduce this problem. I have the dll that I can email to you along with a test php script so you can see the error in action on your own system. I also have the Visual Basic library that does the same thing except in VB I can set the property that we are not being allowed to set in PHP without getting the error.

Please let me know where to email the libraries to or if you need any other information to move forward with this.  Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 16:01:27 2024 UTC