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:9
Avg. Score:4.2 ± 1.3
Reproduced:6 of 7 (85.7%)
Same Version:3 (50.0%)
Same OS:4 (66.7%)
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:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 06:02:13 2014 UTC