Bug #44578 [Opn->Fbk]: Strange Behavior of PHP using COM Object

From: Date: Thu, 06 Feb 2020 14:07:33 +0000
Subject: Bug #44578 [Opn->Fbk]: Strange Behavior of PHP using COM Object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225390@lists.php.net to get a copy of this message
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 +Status: Feedback Type: Bug Package: COM related Operating System: Windows XP PHP Version: 5.2.5 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2019-06-19 17:51:38] cmb@php.net This should likely have been $propriete->Value["Label"][0] = "New Label"; ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=44578 -- Edit this bug report at https://bugs.php.net/bug.php?id=44578&edit=1

« previous php.bugs (#225390) next »