php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48061 Exception when passing array by ref to COM method
Submitted: 2009-04-23 13:43 UTC Modified: 2009-04-27 17:24 UTC
Votes:12
Avg. Score:4.1 ± 1.3
Reproduced:9 of 10 (90.0%)
Same Version:3 (33.3%)
Same OS:5 (55.6%)
From: kmb at kai-m-becker dot de Assigned:
Status: Open Package: COM related
PHP Version: 5.2.9 OS: Windows XP SP3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kmb at kai-m-becker dot de
New email:
PHP Version: OS:

 

 [2009-04-23 13:43 UTC] kmb at kai-m-becker dot de
Description:
------------
When calling a COM method with an array argument by reference, a com_exception "type mismatch" is thrown. 

Problem occurs only with arrays(!) as arg by ref. 
Scalar types work fine as arg by ref.

php-5.2.9\ext\com_dotnet\com_com.c shows that the exception comes from IDispatch_Invoke() (Windows-API) called in php_com_invoke_helper().

Reproduce code:
---------------
$opc = new COM('Matrikon.OPC.Automation'); // <-- certified COM App
$opc->Connect('Matrikon.OPC.Simulation.1');
$opcgroup = $opc->OPCGroups->Add("mes");

// some code to fill $serverhandles

$values = array();
$errors = array();
$qualities = array();
$timestamps = array();

// function SyncRead( // acc. to com_print_typeinfo() and OPC-spec.
//    /* VT_I2 [2] [in] */ $Source,
//    /* VT_I4 [3] [in] */ $NumItems,
//    /* VT_PTR [26] [in] --> VT_SAFEARRAY [27]  */ &$ServerHandles,
//    /* VT_PTR [26] [out] --> VT_SAFEARRAY [27]  */ &$Values,
//    /* VT_PTR [26] [out] --> VT_SAFEARRAY [27]  */ &$Errors,
//    /* VT_PTR [26] [out] --> VT_VARIANT [12]  */ &$Qualities,
//    /* VT_PTR [26] [out] --> VT_VARIANT [12]  */ &$TimeStamps
//    )

$opcgroup->SyncRead(
   OPC_DS_CACHE, count($serverhandles), $serverhandles, // [in] args
   $values, $errors, $qualities, $timestamps // [out] args
);

Expected result:
----------------
Successful call to SyncRead().

Actual result:
--------------
com_exception: Parameter 4: Typkonflikt (= type mismatch)

#0 opc_read_test.php(148): variant->SyncRead(1, 56, Array, Object(variant), Object(variant), Object(variant), Object(variant))
#1 {main}


Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 15:01:32 2024 UTC