[Tickets #3957] NEW: call_user_func always passes copy of Turba object to _turba_hook_encode_{attribute}

bugs@bugs.horde.org bugs at bugs.horde.org
Fri May 19 02:44:28 PDT 2006


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=3957
-----------------------------------------------------------------------
 Ticket             | 3957
 Created By         | avo at trustsec.de
 Summary            | call_user_func always passes copy of Turba object to _turba_hook_encode_{attribute}
 Queue              | Turba
 Version            | 2.1.1
 State              | Unconfirmed
 Priority           | 2. Medium
 Type               | Bug
 Owners             | 
+New Attachment     | patch-turba_lib_Object_php.diff
-----------------------------------------------------------------------


avo at trustsec.de (2006-05-19 02:44) wrote:

The hook functions _turba_hook_encode_{attribute} and
_turba_hook_decode_{attribute} always get a copy of the Turba object since
the hook functions are called with call_user_func. It's not possible to get
a reference to the object and thus it isn't possible to modify the object in
the hook function.

For example, I'd like to concatenate the first name and last name and store
that value in the attributes "displayname" and "cn". I'd also like to
construct the "postalAddress" from "street", "postalCode", "location" etc.

This is only possible if I can get a reference to the Turba object instead
of a copy. Here's an example hook function:

function _turba_hook_encode_firstname($new_value, $old_value,
&$turba_object)
{
    $firstname = $new_value;
    $lastname = $turba_object->getValue('firstname');
    $name = $firstname . ' ' . $lastname;
    $turba_object->setValue('displayname', $name);
    $turba_object->setValue('cn', $name);
    return $new_value;
}

I've attached a small patch that replaces call_user_func in
turba/lib/Object.php with direct function calls.

It's highly unlikely that this change will break existing hook functions. I
don't think that anyone has requested a reference to the Turba object but
then expects to get a copy of the object.




More information about the bugs mailing list