php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44578 Strange Behavior of PHP using COM Object
Submitted: 2008-03-31 12:39 UTC Modified: 2019-06-19 17:51 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: hargael at gmail dot com Assigned:
Status: Open Package: COM related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hargael at gmail dot com
New email:
PHP Version: OS:

 

 [2008-03-31 12:39 UTC] 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.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-08 12:46 UTC] 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.
 [2009-02-27 09:34 UTC] 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.
 [2018-05-05 19:36 UTC] requinix@php.net
...
 [2018-05-05 19:36 UTC] 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.
 [2019-06-19 17:51 UTC] cmb@php.net
This should likely have been

  $propriete->Value["Label"][0] = "New Label";
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 20 09:01:23 2020 UTC