php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27974 COM object and arrays
Submitted: 2004-04-13 09:02 UTC Modified: 2004-04-23 21:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot Assigned: wez (profile)
Status: Closed Package: COM related
PHP Version: 5.0.0RC2-dev 23-04-2004 06:30 OS: windows2000 (5.00.2185) sp4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot
New email:
PHP Version: OS:

 

 [2004-04-13 09:02 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Description:
------------
I try to update a multi valued Active Directory attribute.  The (COM) function expects an array as the third parameter.

When the function is called, PHP produces an error. (See Reproduce code :)

I tried the same on my second server that's running:

PHP 4.3.4 (cli) (built: Nov 2 2003 23:47:34)

The code is executed without any problems.

Did something changed in the way PHP treats arrays, or did COM changed?


Reproduce code:
---------------
<?php
define("APPEND", 3);

$adsi = "cn=user,ou=test,dc=php,dc=net";
$user = new COM("LDAP://" . $adsi);

$user -> PutEx(APPEND, "otherHomePhone", array("123", "456", "789"));
$user -> SetInfo();
?>

Expected result:
----------------
Active Directory should update the multi-valued attribute 'otherHomePhone' with the values specified in the array.

Actual result:
--------------
Exception thrown
File        : C:\php\includes\test.php
Line        : 6
Message     : Source: Active Directory
Description: Unspecified error

Code        : -2147352567
TraceString :
#0 {main}
Array
(
)
Trace       : 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-22 02:52 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

I've just comitted a probable fix; please try the next PHP snapshot (could be up to 3 hours away) and let me know how things go.
 [2004-04-22 13:54 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Hi Wez,

I installed the CVS version [5.0.0RC2-dev, 22 Apr 2004 08:32:53] and did the following tests:

### PHP Code ###
<?php
define("APPEND", 3);

$adsi = "cn=user,ou=test,dc=php,dc=net";
$user = new COM("LDAP://" . $adsi);

$arr = //See the test results!

$user -> PutEx(APPEND, "otherHomePhone", $arr);
$user -> SetInfo();
?>


### Test 1 ###
$arr = array("123", "456", "789");

PHP Warning:  Unknown: COM: converting from PHP array to VARIANT array; only arrays with numeric keys are allowed in C:\php\includes\test.php on line 9
Exception thrown
File        : C:\php\includes\test.php
Line        : 9
Message     : Source: Active Directory
Description: Unspecified error

Code        : -2147352567
TraceString :
#0 {main}

### Test 2 ###
$arr = array(0 => "123", 1 => "456", 2 => "789");

PHP Warning:  Unknown: COM: converting from PHP array to VARIANT array; only arrays with numeric keys are allowed in C:\php\includes\test.php on line 9
Exception thrown
File        : C:\php\includes\test.php
Line        : 9
Message     : Source: Active Directory
Description: Unspecified error

Code        : -2147352567
TraceString :
#0 {main}

As you see, both tests failed.
I hope these tests will help you.

Best regards,
Edwin.
 [2004-04-22 16:28 UTC] wez@php.net
My fix was too paranoid; I've updated it; please try the next snapshot.
 [2004-04-23 13:33 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
I installed the CVS version [5.0.0RC2-dev, 23 Apr 2004 06:30] and did the following tests:

### PHP Code ###
<?php
define("APPEND", 3);

$adsi = "cn=user,ou=test,dc=php,dc=net";
$user = new COM("LDAP://" . $adsi);

$arr = array("123", "456", "789");

$user -> PutEx(APPEND, "otherHomePhone", $arr);
$user -> SetInfo();

$arr2 = $user -> GetEx("otherHomePhone");
?>

### Test 1 ###
$cnt = count($arr2);
for($i = 0; $i < $cnt; $i++) {
	print $arr[$i] . "\n";
}
//Only the 1st of 3 elements is printed
//count function results 1. wrong! 3 elements in array

### Test 2 ###
foreach($arr2 as $val) {
	print $val . "\n";
}
//All 3 elements are printed!

### Test 3 ###
print_r($arr2);
//Results: variant Object

The COM function PutEx on line 9 works fine!!! Active directory is updated with the correct values in array.
The COM function GetEx on line 12 has a small problem.
There's no array returned in the function, but an variant object.
 [2004-04-23 15:21 UTC] wez@php.net
What you describe now is expected behaviour; take a look
at http://www.zend.com/php5/articles/php5-dotnet.php for
more information on COM in PHP 5.

The only problem now is that count() doesn't return sensible values for overloaded objects; this is a general
issue and not COM specific (so it's a different bug).

I'll see what can be done about that.


 [2004-04-23 21:24 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Thanks for your support wez!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC