php.net |  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
Votes:3
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
 [2019-05-01 18:57 UTC] uther240 at gmail dot com
Description:
------------
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 https://github.com/php/php-src/blob/master/ext/ldap/ldap.c 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.

thanks

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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-01 22:20 UTC] cmb@php.net
-Assigned To: +Assigned To: mcmic
 [2019-05-01 22:20 UTC] cmb@php.net
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] mcmic@php.net
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 Nov 13 16:01:31 2024 UTC