Summary | Kolab_Storage: PHP error on modifying contact picture |
Queue | Horde Framework Packages |
Queue Version | Git master |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | jan (at) horde (dot) org |
Requester | thomas.jarosch (at) intra2net (dot) com |
Created | 06/18/2014 (4071 days ago) |
Due | |
Updated | 03/24/2015 (3792 days ago) |
Assigned | 06/20/2014 (4069 days ago) |
Resolved | 03/23/2015 (3793 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
commit 984ec55759dd59390686122d37722dfb4b9f4884
Author: Jan Schneider <jan@horde.org>
Date: Tue Mar 24 12:18:53 2015 +0100
Deal with both formats of the _attachments hash (
Bug #13268).In the end I was able to reproducable that edge case.
There is no use in trying to clean this mess up, because it would
break the
_attachments API that is used outside of Kolab_Storage. This
needs refactoring
for H6.
.../lib/Horde/Kolab/Storage/Cache/Data.php | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
http://github.com/horde/horde/commit/984ec55759dd59390686122d37722dfb4b9f4884
talked about. Probably just some stale and broken cache entries from
development.
(will take some time though until I get to it)
Assigned to Jan Schneider
State ⇒ Resolved
about. Probably just some stale and broken cache entries from
development.
commit 6aec869cebdc7e7315f4dfd3624901363449bb60
Author: Jan Schneider <jan@horde.org>
Date: Fri Mar 20 19:47:38 2015 +0100
[jan] Fix deleting object attachments from cache (
Bug #13268)..../lib/Horde/Kolab/Storage/Cache/Data.php | 2 +-
framework/Kolab_Storage/package.xml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
http://github.com/horde/horde/commit/6aec869cebdc7e7315f4dfd3624901363449bb60
New Attachment: 0001-Correctly-remove-old-attachments-from-cache-during-u.patch
and found out what's going on:
The $delete() array contains a list of "IMAP uids" (=backend IDs)
that got deleted - including the corresponding object uid.
When you update a contact in turba, $_data[self::OBJECTS][$object_id]
will contain the *current* datastructure as passed on by the turba
Kolab driver.
There is no 'id' column in '_attachments' as
the '_attachments' datastructure looks like this:
-------------------------
Array
(
[photo.jpg] => Array
(
[type] => image/jpeg
[content] => Resource id
#331)
)
-------------------------
The transformation of that data structure for the on-disc format
of the cache happens a few lines below.
Things are different when you delete a contact,
'_attachments' then looks like this as it's not
updated by the turba Kolab driver itself:
-------------------------------------------------------
[_attachments] => Array
(
[id] => Array
(
[0] => photo.jpg
)
[type] => Array
(
[image/jpeg] => Array
(
[0] => photo.jpg
)
)
)
-------------------------------------------------------
Please apply the attached patch to handle both cases.
I've tested the patch with debug statements in place
to verify it does delete the correct attachment
in both the modify and delete case of a contact object.
store() ($objects array with '_attachments' being an ID->attachment
hash) and how they are stored in the Data object ($this->_data with
'_attachments' being a list of attachment hashes).
How did you actually trigger an error with the current code? Editing
a contact picture with the Horde_Form image editing buttons worked
without problems.
produced email,
it triggers the given warning for me every time on modification (using
git "master").
The foreach() calls I provided are in the same function "store()", so
it's the same datastructure.
To me it looks like $object[_attachments[]['id']] is used before it's
actually built.
If you look at the code, the second iteration is filling in the 'id' field.
--------------------------------------------------------
foreach ($object['_attachments'] as $id => $attachment) {
$attachments['id'][] = $id;
--------------------------------------------------------
did you actually trigger an error with the current code? Editing a
contact picture with the Horde_Form image editing buttons worked
without problems.
or notices.
of the '_attachments' array is already the id?
The code in question iterates of the attachments like this:
------------------------------------------
foreach ($object['_attachments']['id'] as $id) {
------------------------------------------
Other pieces of code iterate like this:
------------------------------------------
foreach ($object['_attachments'] as $id => $attachment) {
------------------------------------------
State ⇒ Feedback
Patch ⇒ No
State ⇒ Unconfirmed
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Kolab_Storage: PHP error on modifying contact picture
Type ⇒ Bug
Priority ⇒ 1. Low
when you modify a contact picture in turba (say: rotate it), the
following error is logged:
2014-06-19T15:52:34+02:00 WARN: HORDE [turba] PHP ERROR: Invalid
argument supplied for foreach() [pid 2863 on line 461 of
"/datastore/DEVEL/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cache/Data.php"]
The structure of $object['_attachments'] looks like this:
---------------------------------
Array
(
[photo.jpg] => Array
(
[type] => image/jpeg
[content] => Resource id
#331)
)
---------------------------------
-> no "id" value in there.
Cheers,
Thomas