php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72569 DOTNET/COM array parameters broke in PHP7 (regresion)
Submitted: 2016-07-09 20:08 UTC Modified: 2016-07-12 15:03 UTC
From: deivid dot garcia dot garcia at gmail dot com Assigned: ab (profile)
Status: Closed Package: COM related
PHP Version: 7.0.8 OS: Windows 10.1
Private report: No CVE-ID: None
 [2016-07-09 20:08 UTC] deivid dot garcia dot garcia at gmail dot com
Description:
------------
Arrays passed to .Net when calling .Net object methods using COM class (probably DOTNET too but have not tested) arrive as empty arrays.

This was NOT happening in PHP < 7, it's a regression. Other simple types are passed on properly (such as strings).

Test script:
---------------
The bug CANNOT be demonstrated without building a specific .Net dll that takes an array as input.

In .Net:

public object MyNiceMethod(object[] parameters)
{
  // In PHP7 parameters comes in as an EMPTY array
  // when in PHP < 7 it was an array of string, integers and whatever
  // you passed in from PHP.
}

In PHP:

$a = new COM("{CLASSID}");
$a->MyNiceMethod(["string1", "string2", 56, "string3", [1, 2, 3]]);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-11 01:25 UTC] cmb@php.net
-Package: *Compression related +Package: COM related
 [2016-07-11 13:22 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-07-11 13:22 UTC] ab@php.net
Thanks for the report. I'm willing to fix this issue, but lack on a way to reproduce. Could you please supply a complete code for the C# class and the way to bind it in PHP, so debugging can be done?

Thanks.
 [2016-07-11 15:41 UTC] deivid dot garcia dot garcia at gmail dot com
I was able to investigate this further and it looks like the issue is not strictly related to the fact that an array is being passed, but that the array contains at least *one* reference.

I have built a demo script + dll and posted instructions on this Github repo:

https://github.com/david-garcia-garcia/72569test

What happens is that, if you pass an array to .Net, and any of the elements inside the array is a reference, then the whole array arrives to .Net as full of NULLS (keeping the original length though).

This did not happen in previous versions of PHP.

If you run the script in PHP 5.6 x86 NTS and PHP 7.0.8 NTS x64 you will se that it outputs different data.

Thanks!
 [2016-07-12 12:59 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e8dbb3e5d763166e6f03903c931161d5f2706ed
Log: Fixed bug #72569 DOTNET/COM array parameters broke in PHP7
 [2016-07-12 12:59 UTC] ab@php.net
-Status: Feedback +Status: Closed
 [2016-07-12 13:01 UTC] ab@php.net
-Status: Closed +Status: Feedback
 [2016-07-12 13:01 UTC] ab@php.net
Thanks for making repro so easy :) I've just pushed a fix to this, could you please check these builds with your app? http://windows.php.net/downloads/snaps/ostc/72569/

Thanks.
 [2016-07-12 13:43 UTC] deivid dot garcia dot garcia at gmail dot com
Works. Thanks!
 [2016-07-12 15:03 UTC] ab@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: ab
 [2016-07-12 15:03 UTC] ab@php.net
Closing then. Cheers!
 [2016-07-20 11:30 UTC] davey@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e8dbb3e5d763166e6f03903c931161d5f2706ed
Log: Fixed bug #72569 DOTNET/COM array parameters broke in PHP7
 [2016-10-17 10:11 UTC] bwoebi@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e8dbb3e5d763166e6f03903c931161d5f2706ed
Log: Fixed bug #72569 DOTNET/COM array parameters broke in PHP7
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC