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: 2020-02-16 04:22 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: cmb (profile)
Status: No Feedback Package: COM related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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";
 [2020-02-06 14:07 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-02-06 14:07 UTC] cmb@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2020-02-16 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 14:01:23 2021 UTC