From: mcboog at zonnet dot nl Operating system: Windows XP Professional PHP version: 5.1.4 PHP Bug Type: COM related Bug description: Multi-dimensional array between PHP and COM
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' -- Edit bug report at http://bugs.php.net/?id=37965&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37965&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37965&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37965&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37965&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37965&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37965&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37965&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37965&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37965&r=support Expected behavior: http://bugs.php.net/fix.php?id=37965&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37965&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37965&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37965&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37965&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37965&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37965&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37965&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37965&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37965&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37965&r=mysqlcfg