php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37965 Multi-dimensional array between PHP and COM
Submitted: 2006-06-29 21:03 UTC Modified: 2013-12-13 07:47 UTC
Votes:13
Avg. Score:4.2 ± 1.5
Reproduced:10 of 10 (100.0%)
Same Version:4 (40.0%)
Same OS:8 (80.0%)
From: mcboog at zonnet dot nl Assigned:
Status: Open Package: COM related
PHP Version: 5.1.4 OS: Windows XP Professional
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-06-29 21:03 UTC] mcboog at zonnet dot nl
Description:
------------
As noticed in two previous bug-reports (//http://bugs.php.net/bug.php?id=35956 & //http://bugs.php.net/bug.php?id=33108) there is a problem with retrieving a multi-dimensional array from a COM-object. This problem is addressed on the website of Zend (http://www.zend.com/manual/faq.com.php, question #2), but should be resolved in PHP5 (http://www.zend.com/manual/ref.com.php, Arrays and Array-style COM properties).

Reproduce code:
---------------
$obj = new COM('com.object.version');
$varIn = new Variant;
$varOutSimple = new Variant;
$varOutComplex = new Variant;
$obj->internal_com_method($varIn, $varOutSimple, $varOutComplex)

This method has te following definition (part of output of com_print_typeinfo($obj)):
function internal_com_method(
/* VT_I4 [3] [in] */ $varIn,
/* VT_PTR [26] [in][out] --> VT_VARIANT [12]  */ &$varOutSimple,
/* VT_PTR [26] [in][out] --> VT_VARIANT [12]  */ &$varOutComplex
) { /* Method internal_com_method }

$varIn is just an integer. $varOutSimple is a single-dimension array, $varOutComplex is a double-dimension array.

Calling NumberOfFields;
1. print $varOutSimple->NumberOfFields;
2. print $varOutComplex->NumberOfFields;

Count
3. print count($varOutSimple);
4. print count($varOutComplex);

Getting value with string as key
5. print $varOutSimple['key'];
6. print $varOutComplex['key'];

Doing foreach:
7. foreach ($varOutSimple as $key => $value) {
 print $value;
}
8. foreach ($varOutComplex as $key => $value) {
 print $value;
}


Expected result:
----------------
1. output 11
2. output 52
3. output 11
4. output 52
5. output $value
6. output $value
7. output $value
8. output $value

Actual result:
--------------
1. output 11
2. Error: Uncaught exception 'com_exception' with message 'this variant has no properties'.
3. output 1 (irrelevant, works at 5. with direct string-key access)
4. output 52
5. output $value
6. Apache (Apache/2.0.55 (Win32) ) crashes
7. Error:  Uncaught exception 'Exception' with message 'Object of type variant did not create an Iterator'
8. Error: Can only handle single dimension variant arrays (this array has 2) & (NB!) Uncaught exception 'Exception' with message 'Object of type variant did not create an Iterator'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-05 09:06 UTC] mcboog at zonnet dot nl
Is there a reason why there is still no reaction on my bug report?
 [2006-07-05 21:13 UTC] mcboog at zonnet dot nl
Forget everything above.

Description:
When accessing a multi-dim array from COM-object Apache2 crashes with error [Wed Jul 05 22:50:21 2006] [notice] Parent: child process exited with status 3221225477 -- Restarting. This error-code seems to be related with array access problems.
When I use the COM-object with VBScript I can access the value of the multi-dim array with: multiArray(1,1), which should have an equivalent in PHP by $multiArray[1][1].

Reproduce code:
<?php
$obj = new COM('com_object');
$obj->function_call($multiArray);
print $multiArray[1][1];
?>

Expected result:
output value.

Actual result:
Apache crashes.
 [2006-07-05 21:20 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2006-07-06 12:10 UTC] mcboog at zonnet dot nl
Following the instructions for Generating a backtrace on Win32 gave me this backtrace:

PHP5TS! 100af45c()
 [2006-07-06 12:40 UTC] mcboog at zonnet dot nl
Sorry man, never done this before... 
Now I got the following backtrace:

convert_to_long_base(_zval_struct * 0x100ea6d5, int 0) line 306 + 9 bytes
saproxy_read_dimension(_zval_struct * 0x10076460, _zval_struct * 0x100369b1, int 17481848, void * * * 0x010ac064) line 176
ZEND_FETCH_DIM_R_SPEC_CV_CONST_HANDLER(_zend_execute_data * 0x10019515, void * * * 0x010ac530) line 20802
execute(_zend_op_array * 0x7c9106eb, void * * * 0x1000948d) line 92 + 12 bytes
NTDLL! 7c9106eb()
NTDLL! 7c9106eb()
 [2006-07-06 12:49 UTC] tony2001@php.net
Assigned to the maintainer.
 [2013-12-13 07:47 UTC] wez@php.net
-Status: Assigned +Status: Open -Assigned To: wez +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu May 23 08:01:29 2019 UTC