Bug #77958 [Com]: values in ldap_modify_batch must be "string"

From: Date: Thu, 09 May 2019 13:40:11 +0000
Subject: Bug #77958 [Com]: values in ldap_modify_batch must be "string"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220799@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77958&edit=1 ID: 77958 Comment by: mcmic@php.net Reported by: uther240 at gmail dot com Summary: values in ldap_modify_batch must be "string" Status: Assigned Type: Bug Package: LDAP related Operating System: Debian PHP Version: 7.1.28 Assigned To: mcmic Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2019-05-01 22:20:54] 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-01 18:57:53] 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 ] ]); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77958&edit=1

« previous php.bugs (#220799) next »