php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47401 Can't instantiate VARIANT objects with VT_BYREF flag
Submitted: 2009-02-16 05:26 UTC Modified: 2020-02-07 11:47 UTC
Votes:5
Avg. Score:4.2 ± 1.0
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:3 (60.0%)
From: setvik at gmail dot com Assigned:
Status: Open Package: COM related
PHP Version: 5.2.9RC2 OS: Windows Server 2003
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-02-16 05:26 UTC] setvik at gmail dot com
Description:
------------
PHP crashes when instantiating a VARIANT object with the BYREF flag.

This makes it impossible to pass arguments to COM functions that require them to be passed by reference (MS Word's PrintOut function, for example). (Tested in PHP 5.2.8 and 5.2.9rc2).

Reproduce code:
---------------
$var = new VARIANT(TRUE, VT_BOOL|VT_BYREF);

Expected result:
----------------
Execution should continue, and I should be able to pass $var to a windows com function:

EXAMPLE:

$word = new COM("Word.Application");
$word->Documents->Open("mydoc.doc");

$var = new VARIANT(TRUE, VT_BOOL|VT_BYREF);
$word->ActiveDocument->PrintOut($var);

Actual result:
--------------
PHP Fatal error:  Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.
' in D:\test.php:1
Stack trace:
#0 D:\test.php(1): variant->variant(true, 16395)
#1 {main}
  thrown in D:\test.php on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-07 11:47 UTC] cmb@php.net
> PHP crashes when instantiating a VARIANT object with the BYREF
> flag.

No, it does not crash; it throws an exception what is something
completely different.

> This makes it impossible to pass arguments to COM functions that
> require them to be passed by reference (MS Word's PrintOut
> function, for example).

That looks like a bad example, though, since according to the
docs[1], the first parameter (Background) is not passed by ref.

[1] <https://docs.microsoft.com/en-us/office/vba/api/word.document.printout>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC