Bug #44578 [Opn]: Strange Behavior of PHP using COM Object
Edit report at https://bugs.php.net/bug.php?id=44578&edit=1
ID: 44578
Updated by: cmb@php.net
Reported by: hargael at gmail dot com
Summary: Strange Behavior of PHP using COM Object
Status: Open
Type: Bug
Package: COM related
Operating System: Windows XP
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
This should likely have been
$propriete->Value["Label"][0] = "New Label";
Previous Comments:
------------------------------------------------------------------------
[2018-05-05 19:36:58] requinix@php.net
Original report:
Description:
------------
I've a problem with COM objects.
It's very similar to the bug #33734. In fact, I think that it is the same problem but the bug
is supposed to be fixed since 5.1.0. I use the 5.2.5 and have the same problem.
Excuse me for my clumsy english, I hope that my report will be readable.
Reproduce code:
---------------
Here is the code :
<?php
// Creation of the COM object $obj_persist
$obj_persist = new COM("PERSIST.PersistCtrl.1")or die("Error");
$obj_appli = $obj_persist->Applications->Add($path);
$obj_unite = $obj_appli->Units->Add("foo");
$obj_instance = $obj_unite->objects->add($nom_instance);
$sous_objet = $obj_instance->collection("Objects");
$propriete = $sous_objet->Item("alm");
echo "Label Value : " . $propriete->Value("Label",0); //Returns the good
Value
// Test 1
$propriete->Value("Label",0) = "New Label";
// Fatal Error
//Test 2
$propriete->Value["Label",0] = "New Label";
// Invalid number of parameters.
Expected result:
----------------
I've tried many ways of writing the $propriete->Value["Label",0]. With (), [], mix
of both. I cannot write on the value.
I though it was a read-only value but when I tried with VBa, it worked perfectly. Here is the code.
Dim SsObjs as PrsCollObjects
Set SsObjs = MyInst.Collection("Objects")
Set MyObject = SsObjs.Item("Fault")
MyObject.Value("Label", 0) = "Défaut pompe 1"
Actual result:
--------------
Result of TEST 1 with () :
Fatal error: Can't use method return value in write context in C:\wamp\www\Test COM\index.php
on line 71
Result of TEST 2 with [] :
Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000e]
Nombre de param?tres non valide. ' in C:\wamp\www\Test COM\index.php:69 Stack trace: #0
C:\wamp\www\Test COM\index.php(69): unknown() #1 {main} thrown in C:\wamp\www\Test COM\index.php on
line 69
Depending on the way I write with [], I also have an "Unexpected ','" error.
------------------------------------------------------------------------
[2018-05-05 19:36:11] requinix@php.net
...
------------------------------------------------------------------------
[2009-02-27 09:34:27] hargael at gmail dot com
Is there a way I can help in order to make this bug evolve ?
I can provide any requested logs and can perform tests to help to solve this problem because I
really need this feature.
I'm not really keen on using an ASP page to make this single function.
Regards.
------------------------------------------------------------------------
[2008-07-08 12:46:07] spijoel at gmail dot com
I have the same problem (Fatal error: Can't use method return value in write context in ...),
with PHP 5.2.6 , Apache 2.2.9 , and Windows 2003 Server.
I'm not able to do this:
$obj->Attribute('data1') = "test";
This is also not working like this:
$obj->Attribute['data1'] = "test";
and it's working in VBS so I know it should work here also.
------------------------------------------------------------------------
[2008-03-31 12:39:49] hargael at gmail dot com
Description:
------------
I've a problem with COM objects.
It's very similar to the bug #33734. In fact, I think that it is the same problem but the bug
is supposed to be fixed since 5.1.0. I use the 5.2.5 and have the same problem.
Excuse me for my clumsy english, I hope that my report will be readable.
Reproduce code:
---------------
Here is the code :
<?php
// Creation of the COM object $obj_persist
$obj_persist = new COM("PERSIST.PersistCtrl.1")or die("Error");
$obj_appli = $obj_persist->Applications->Add($path);
$obj_unite = $obj_appli->Units->Add("foo");
$obj_instance = $obj_unite->objects->add($nom_instance);
$sous_objet = $obj_instance->collection("Objects");
$propriete = $sous_objet->Item("alm");
echo "Label Value : " . $propriete->Value("Label",0); //Returns the good
Value
// Test 1
$propriete->Value("Label",0) = "New Label";
// Fatal Error
//Test 2
$propriete->Value["Label",0] = "New Label";
// Invalid number of parameters.
Expected result:
----------------
I've tried many ways of writing the $propriete->Value["Label",0]. With (), [], mix
of both. I cannot write on the value.
I though it was a read-only value but when I tried with VBa, it worked perfectly. Here is the code.
Dim SsObjs as PrsCollObjects
Set SsObjs = MyInst.Collection("Objects")
Set MyObject = SsObjs.Item("Fault")
MyObject.Value("Label", 0) = "D?faut pompe 1"
Actual result:
--------------
Result of TEST 1 with () :
Fatal error: Can't use method return value in write context in C:\wamp\www\Test COM\index.php
on line 71
Result of TEST 2 with [] :
Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000e]
Nombre de param?tres non valide. ' in C:\wamp\www\Test COM\index.php:69 Stack trace: #0
C:\wamp\www\Test COM\index.php(69): unknown() #1 {main} thrown in C:\wamp\www\Test COM\index.php on
line 69
Depending on the way I write with [], I also have an "Unexpected ','" error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44578&edit=1
Thread (8 messages)