|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77958 values in ldap_modify_batch must be "string"
Submitted: 2019-05-01 18:57 UTC Modified: 2019-05-01 22:20 UTC
Avg. Score:2.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: uther240 at gmail dot com Assigned: mcmic (profile)
Status: Assigned Package: LDAP related
PHP Version: 7.1.28 OS: Debian
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.
Block user comment
Status: Assign to:
Bug Type:
From: uther240 at gmail dot com
New email:
PHP Version: OS:


 [2019-05-01 18:57 UTC] uther240 at gmail dot com
I am not entirely certain this is a "bug" per se, but think it is at least not functioning the way it should...

when modifying a value in ldap that is inherently a number (like a phone number), it throws the error:  ldap_modify_batch(): Each element of a 'values' array must be a string.

Though I understand that this is by-design... I feel that the 'value' passed should be a 'scalar', not explicitly a string...  i.e. it did not seem intuitive that I should have to cast the number to string first: (e.g.  $value . '').

There may not be a reasonable way to fix this however, as there is no IS_SCALAR in zend_types (rightly so... as we are talking about C data types, not php data types in this context).  Given the nature of the issue, I think the easiest fix would be in line 2704, by adding a check for IS_(LONG|DOUBLE) and performing an snprintf on it, and that just may not be worth it... I leave it to you.


Test script:
ldap_modify_batch($connection, $dn, [
    'attrib'  => 'mobile',
    'modtype' => LDAP_MODIFY_BATCH_ADD,
    'values'  => [ 1234567 ]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-01 22:20 UTC]
-Assigned To: +Assigned To: mcmic
 [2019-05-01 22:20 UTC]
Besides that I don't agree that a phone number is inherently a
number, internally calling convert_to_string() might be an option.

Anyhow, could you have a look at this, Côme?
 [2019-05-09 13:40 UTC]
A phone number is definitely a string, but indeed it would make more sense that the LDAP call converts everything to string and only triggers an error if that fails.

Please use (string)$value for cast, and not $value.''.

It seems ldap_mod_replace and the others are using convert_to_string_ex so it would be consistent for ldap_modify_batch to do the same.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 10:01:28 2024 UTC