summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2006-12-24 10:00:59 +0000
committerRob Richards <rrichards@php.net>2006-12-24 10:00:59 +0000
commitb7ec6f90e016da3a76f487f62b9694f3184dc2c6 (patch)
treeb2bbb519c3808d3b5f83257b9c777c6b1aada350
parent6077df1a03a91ce2fe17ff1a7bdeb979a1a5e842 (diff)
downloadphp-git-b7ec6f90e016da3a76f487f62b9694f3184dc2c6.tar.gz
- fix bug #33386 (ScriptControl only sees last function of class): com_wrapper.c
- fix bug #37588 (COM Property propputref converts to PHP function and can't be accesed): com_handlers.c - fix bug #39596 (Creating Variant of type VT_ARRAY): com_variant.c - add tests
-rw-r--r--ext/com_dotnet/com_handlers.c2
-rw-r--r--ext/com_dotnet/com_variant.c35
-rw-r--r--ext/com_dotnet/com_wrapper.c2
-rw-r--r--ext/com_dotnet/tests/bug33386.phpt40
-rw-r--r--ext/com_dotnet/tests/bug39596.phpt23
5 files changed, 92 insertions, 10 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index a422b32041..6ca7061cb2 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -76,7 +76,7 @@ static void com_property_write(zval *object, zval *member, zval *value TSRMLS_DC
convert_to_string_ex(&member);
if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
- DISPATCH_PROPERTYPUT, &v, 1, &value TSRMLS_CC)) {
+ DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &v, 1, &value TSRMLS_CC)) {
VariantClear(&v);
}
} else {
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index a904a08ac0..733f0bcd50 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -289,19 +289,36 @@ PHP_FUNCTION(com_variant_create_instance)
php_com_variant_from_zval(&obj->v, zvalue, obj->code_page TSRMLS_CC);
}
- if (ZEND_NUM_ARGS() >= 2) {
+ /* Only perform conversion if variant not already of type passed */
+ if ((ZEND_NUM_ARGS() >= 2) && (vt != V_VT(&obj->v))) {
+
+ /* If already an array and VT_ARRAY is passed then:
+ - if only VT_ARRAY passed then do not perform a conversion
+ - if VT_ARRAY plus other type passed then perform conversion
+ but will probably fail (origional behavior)
+ */
+ if ((vt & VT_ARRAY) && (V_VT(&obj->v) & VT_ARRAY)) {
+ long orig_vt = vt;
+
+ vt &= ~VT_ARRAY;
+ if (vt) {
+ vt = orig_vt;
+ }
+ }
- res = VariantChangeType(&obj->v, &obj->v, 0, (VARTYPE)vt);
+ if (vt) {
+ res = VariantChangeType(&obj->v, &obj->v, 0, (VARTYPE)vt);
- if (FAILED(res)) {
- char *werr, *msg;
+ if (FAILED(res)) {
+ char *werr, *msg;
- werr = php_win_err(res);
- spprintf(&msg, 0, "Variant type conversion failed: %s", werr);
- LocalFree(werr);
+ werr = php_win_err(res);
+ spprintf(&msg, 0, "Variant type conversion failed: %s", werr);
+ LocalFree(werr);
- php_com_throw_exception(res, msg TSRMLS_CC);
- efree(msg);
+ php_com_throw_exception(res, msg TSRMLS_CC);
+ efree(msg);
+ }
}
}
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index 576fa26bb9..0a7b275f55 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -477,6 +477,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen-1, 1);
+ pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
@@ -508,6 +509,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen-1, 1);
+ pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt
new file mode 100644
index 0000000000..e57f1274c1
--- /dev/null
+++ b/ext/com_dotnet/tests/bug33386.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #33386 (ScriptControl only sees last function of class)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class twoFuncs {
+ public function func1() { echo " func one\n"; }
+ public function func2() { echo " func two\n"; }
+}
+
+try {
+ $ciTF = new twoFuncs;
+
+ $oScript = new COM("MSScriptControl.ScriptControl");
+ $oScript->Language = "VBScript";
+
+ $oScript->AddObject ("tfA", $ciTF, true);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfA.func$i");
+ $oScript->ExecuteStatement ("func$i");
+ }
+ $oScript->AddObject ("tfB", $ciTF);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfB.func$i");
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+ func one
+ func one
+ func two
+ func two
+ func one
+ func two
diff --git a/ext/com_dotnet/tests/bug39596.phpt b/ext/com_dotnet/tests/bug39596.phpt
new file mode 100644
index 0000000000..dc8d1ef066
--- /dev/null
+++ b/ext/com_dotnet/tests/bug39596.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #39596 (Creating Variant of type VT_ARRAY)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+try {
+ $binding_string = array('aaa','bbb','ccc');
+ $v = new VARIANT( $binding_string, VT_ARRAY );
+ foreach ($v AS $element) {
+ print $element."\n";
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+aaa
+bbb
+ccc