php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11339 COM calls returning arrays ?
Submitted: 2001-06-07 16:22 UTC Modified: 2001-06-11 21:55 UTC
From: pauls at dataworx dot com dot au Assigned:
Status: Closed Package: COM related
PHP Version: 4.0.4pl1 OS: WinNT4.0/SP6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pauls at dataworx dot com dot au
New email:
PHP Version: OS:

 

 [2001-06-07 16:22 UTC] pauls at dataworx dot com dot au
Firstly, my apologies for submitting this as a seperate bug report, it should be added to 11250, however I know my passsword & my email address doesn't seem to suffice as a user name...I get rejected.

I downloaded the latest cvs & used the code in ext/com/conversion.c as a (little) starting point.

Noted that the code required in php_pval_to_variant() is still 'TO DO' and that the code in php_variant_to_pval() for VT_ARRAY probably won't ever get called unless someone purposely designs a COM component that returns a VT_ARRAY with no type....unlikely...but in any case the existing code would break with arrays of type VT_ARRAY|VT_VARIANT which are very common with VB programmers (unfortuntely they write a lot of COM objects).

I have written all of the code nesessary to handle typed and non-typed arrays as value/by ref arguements (the most common type of array arguement to VB COM objects) and to handle return arrays of by value/by reference types using the php snapshot version 4.0.4pl1 snapshot (I know there have been a lot of changes since then, but 4.0.4pl1 works for me and I don't have the time or expertise to pull different versions from cvs & try them). Also, in reading the bug reports before delving into this, I noted that someone needed to be able to accept variant fields of type VT_C (currency) from database requests... so I added (& tested) that while I was there.

As I said, I'm definitely a cvs novice, so if you are interested in blending this code into the later releases (I would definately mess it up !), and receiving a little VB6 test COM dll & php calling code, let me know who to forward it to via email & I will be more than happy to oblige.

Thank you for your your good work !!!

Paul Shortis

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-11 13:55 UTC] phanto@php.net
i can't follow you in all of the mentioned points.

safearray->pval checks for (V_VT(variant) & VT_ARRAY) which is true if the VT_ARRAY bit is set without taking account of the other bits and then calls php_COM_variant_to_pval on every element.

i'd like to see your code and the example com-component. please mail it to me.

harald
 [2001-06-11 21:55 UTC] pauls at dataworx dot com dot au
Hello Harold,

I was referring to the following code snippet in "conversion.c" from last weeks latest cvs download

PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage)
{
    /* Changed the function to return a value for recursive error testing */
    /* Existing calls will be unaffected by the change - so it */
    /* seemed like the smallest impact on unfamiliar code */
    int ret = SUCCESS;

    /* Add SafeArray support */
    switch(var_arg->vt & ~VT_BYREF)
    {
        case VT_ARRAY:
            {

As you know the variant type VT_ARRAY is always OR'd with the array element type even if it is VT_VARIANT so you will never get  a case where var_arg->vt & ~VT_BYREF resolves simply to VT_ARRAY (it should always be VT_ARRAY|* where * is the element type.

I suspect from your comments that you may be looking at different code to me.

Also, while I see the rationale behind using the VARIANT class, it makes the syntax of passing array arguements to COM objects different to passing arrays to other functions and a lot more cumbersome when it can be implimented transparently.

In any case I will email my changes (I haven't bothered with codepage suppoty) to phanto's email address (cos I don't have yours).

Regards, Paul
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 12:03:33 2022 UTC