php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28179 [COM] passing classes as a parameter
Submitted: 2004-04-27 12:02 UTC Modified: 2004-05-03 13:49 UTC
From: arnout at argeweb dot nl Assigned:
Status: Closed Package: COM related
PHP Version: PHP Version 5.0.0RC2 OS: Windows NT 5.2 / Windows 2003
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: arnout at argeweb dot nl
New email:
PHP Version: OS:

 

 [2004-04-27 12:02 UTC] arnout at argeweb dot nl
Description:
------------
I'm trying to pass a COM class into a member function of another COM class object. The second object chokes.

One class is the connection with the database.
The second is something that needs to connect.

Reproduce code:
---------------

$Conn = new COM("some.Conn");
$Conn->Connect( 'database', 'user', 'pass');

// this object is works fine.

$Customer = new COM("some.Customer");
$Customer->Connect( $Conn );  // KLABAM!

Expected result:
----------------
I'd expect the $Customer->Connect() function to accept the $Conn as being a "Conn" object and just connect.

Actual result:
--------------
"Error number: 97
Error description: Can not call friend function on object which is not an instance of defining class"

This error comes from the object. 
The Customer->Connect function calls a friend function to do something with the Conn object. This function does not believe the object is a living Conn object and spittes it out.

The whole thing works perfectly in C, VC++, VB, Jscript, VBscript (ASP) and Delphi.

I've called the company that made the DLL, and they think the Conn object I pass isn't a real Conn object, but a simulation / emulation. Or a "COM" object of course.

I've tried converting it to a more MS-like thing with the VARIANT class, but it doesn't seem to do much good. (type mismatch)

So is this a PHP problem, or didn't the ones who made the DLL read the COM specifications too well?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-27 19:52 UTC] wez@php.net
It could easily be a PHP problem.
Could you paste the IDL for the method in question here please, so that I can make a similar COM object here to
test against.
If you're unsure about how to get it, ask the people
that made the DLL.
 [2004-04-28 09:39 UTC] arnout at argeweb dot nl
I've talked to them. They said an IDL wouldn't do much good because IDL doesn't contain friend functions, only publics.

They offered to create a sober "Hello world" DLL in VB which simulates the case. I'll test again when I get it. If the error occurs again I'll send you the source code + compiled version.

Is that of use to you?
 [2004-04-28 11:11 UTC] wez@php.net
The IDL describes what the method looks like to other COM applications; I need it to see what their object expects and help deduce what might be going wrong.

 [2004-04-28 13:30 UTC] arnout at argeweb dot nl
I received the DLL and the error's still there.

http://www.argeweb.nl/php/PHPTest.zip

This file contains the DLL, the sourcecodes, an example and a readme. No IDL but I think this might be even better.
 [2004-04-28 17:12 UTC] wez@php.net
Maybe its about time I read the version field of this report.

This problem won't be fixed in PHP 4, but already works just fine in PHP 5.
 [2004-04-29 15:14 UTC] arnout at argeweb dot nl
The problem's still there. 

Fatal error: Uncaught exception 'com_exception' with message 'Source: PHPTest
Description: Can not call friend function on object which is not an instance of defining class' in C:\Program Files\Apache Group\Apache2\htdocs\phptest.php:32 Stack trace: #0 {main} thrown in C:\Program Files\Apache Group\Apache2\htdocs\phptest.php on line 32
 [2004-04-29 16:12 UTC] wez@php.net
The test materials you supplied worked just fine.

 [2004-04-29 16:45 UTC] arnout at argeweb dot nl
I'm using Apache 2 and run 5.0.0RC2 as a module. Maybe that makes some difference?

$Administration = new COM("PHPTest.Administration") or die("huh?");
$Customer = new COM("PHPTest.Customer") or die("what?");
echo $Customer->Connect( $Administration ); // Huge error
 [2004-04-30 11:45 UTC] wez@php.net
What user account is Apache running under?
Does it make a difference if you run it as a different user?
 [2004-05-03 12:57 UTC] arnout at argeweb dot nl
I've got it running now too. It only works if you import the DLL like 'event classes' instead of 'components'.

The real DLL by the way didn't work until I removed it all from the COM+ manager and run regsvr32.exe on it.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 19:05:55 2022 UTC