Bug #47401 [Opn]: Can't instantiate VARIANT objects with VT_BYREF flag
| From: | cmb@php.net | Date: | Fri, 07 Feb 2020 11:47:10 +0000 |
| Subject: | Bug #47401 [Opn]: Can't instantiate VARIANT objects with VT_BYREF flag | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225425@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=47401&edit=1
ID: 47401
Updated by: cmb@php.net
Reported by: setvik at gmail dot com
Summary: Can't instantiate VARIANT objects with VT_BYREF flag
Status: Open
Type: Bug
Package: COM related
Operating System: Windows Server 2003
PHP Version: 5.2.9RC2
Block user comment: N
Private report: N
New Comment:
> 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>
Previous Comments:
------------------------------------------------------------------------
[2009-02-16 05:26:49] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=47401&edit=1