Summary | decode_attribute hook an exceptions |
Queue | Turba |
Queue Version | 3.0.12 |
Type | Enhancement |
State | Feedback |
Priority | 1. Low |
Owners | |
Requester | kd (at) tu-cottbus (dot) de |
Created | 04/02/2012 (4790 days ago) |
Due | |
Updated | 04/04/2012 (4788 days ago) |
Assigned | |
Resolved | |
Milestone | |
Patch | No |
New Attachment: Object.php[1].patch
Change the logic in getValue:
if composite filed - compose it, (don't return)
if hook is defined - call it (don't return)
if image - wrap it into array
return
i.e. different attributes, but the result should be rendered in a
single composite field, after passed through the decode hook.
why the composite field is essential here.
For now i have no new arguments/ideas. Returning an array is ok.
Btw. i havn't had a closer look at the opposite side (setValue/encode),
composite fields seem to be a special case here too (not editable in
the contact form)
i.e. different attributes, but the result should be rendered in a
single composite field, after passed through the decode hook.
Turba 4 instead, with a boolean as the first element, whether the hook
has been called.
reference, and return a
status code?
Horde::callHook() too.
which fields we allow to pass through the hook, just for code-flow
reasons.
side of the map),
this is different from directly to "backend attributes" mapped
"turba-attributes".
What is passed to the hook as the value of a composite field?
I can't imagine a situation, where a composite field *and* a hook for
that field makes sense.
I'd always use a direct mapping and do the other work in the hook.
Isn't a composite field not some kind of simple inline hook?
boolean as the first element, whether the hook has been called.
reference, and return a
status code?
They are a combination of driver values (that should be processed)
which fields we allow to pass through the hook, just for code-flow
reasons.
- to detect, whether or not an attribute has processed, one could
compare the value before and after the hook
- is it really desired, to have composite fields processed by the hook?
They are a combination of driver values (that should be processed)
- are images in this sense not some special kind of composite fields?
hook calls and that's not being logged in Horde::callHook().
It's still a performance degradation to throw and catch so many
exceptions, but I don't see an alternative to reliably skip processing
of individual attributes. Well, maybe we could return an array in
Turba 4 instead, with a boolean as the first element, whether the hook
has been called.
exception instead of the
default passthrough 'return $value'.
by a hook, and thus continue the further processing of composite and
image fields further down in getValue(). If you moved the hook calling
further down, you wouldn't be able to hook into those fields at all.
errors in the Logs.
What I'm doing wrong here?
warnings isn't optimal.
understand what you trying to achieve, besides that it would break
the intended behavior.
i have a personal adressbook 'localsql' (nothing special, mainly the
sample code) and
a global LDAP adressbook 'localldap'. Now i have no field for e.g. '
freebusyUrl' in LDAP.
So i started with:
class Turba_Hooks
{
public function decode_attribute($attribute, $value, $contact)
{
switch ($attribute) {
case 'freebusyUrl':
....
return $url;
}
return $value;
}
}
Now I have 'freebusyUrl' in 'localldap', but magically lost all
pictures in 'localsql'.
To get the pictures in 'localsql' back, i have to throw an exception
instead of the
default passthrough 'return $value'.
Now it works as expected, but i have tons of "No decode handler"
errors in the Logs.
What I'm doing wrong here?
State ⇒ Feedback
understand what you trying to achieve, besides that it would break the
intended behavior.
State ⇒ New
New Attachment: Object.php.patch
Patch ⇒ No
Milestone ⇒
Queue ⇒ Turba
Summary ⇒ decode_attribute hook an exceptions
Type ⇒ Enhancement
Priority ⇒ 1. Low
if for each and every attribute in every source that is not handled by
the hook,
an exception must be thrown
(at least composite fields and images are affected).
In real life only a few attributes from one source need conversion.
One possible solution would be a change in the logic of the getValue method
in Object.php (move the Hook call near the end).