6.0.0-beta1
▾
Tasks
New Task
Search
Photos
Wiki
▾
Tickets
New Ticket
Search
dev.horde.org
Toggle Alerts Log
Help
9/22/25
H
istory
A
ttachments
C
omment
W
atch
Download
Comment on [#3957] call_user_func always passes copy of Turba object to _turba_hook_encode_{attribute}
*
Your Email Address
*
Spam protection
Enter the letters below:
.__ .__ .__ . ..__. [__)| \[__)|__|| | | \|__/| \| ||__\
Comment
> 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.
Attachment
Watch this ticket
N
ew Ticket
M
y Tickets
S
earch
Q
uery Builder
R
eports
Saved Queries
Open Bugs
Bugs waiting for Feedback
Open Bugs in Releases
Open Enhancements
Enhancements waiting for Feedback
Bugs with Patches
Enhancements with Patches
Release Showstoppers
Stalled Tickets
New Tickets
Horde 5 Showstoppers