Summary | foreach with references in the tasklists.inc template |
Queue | Nag |
Queue Version | HEAD |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | |
Requester | wrobel (at) pardus (dot) de |
Created | 03/08/2007 (6678 days ago) |
Due | |
Updated | 06/01/2007 (6593 days ago) |
Assigned | 03/08/2007 (6678 days ago) |
Resolved | 06/01/2007 (6593 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
State ⇒ Resolved
values for read-only share access, but I've committed it for now.
question right now for Horde. Using PHP5 it can be written like this:
this junk is necessary...
$share->get('name')
}
question right now for Horde. Using PHP5 it can be written like this:
foreach ($shares as $key => &$share) {
$share->get('name')
}
references to Horde_Share objects named $shares. When you now process
the array via
foreach ($shares as $key => $share) {
$share->get('name')
}
it creates a copy of the share object if you access it like this.
Here's the proper fix:
foreach(array_keys($shares) as $id) {
$shares[$id]->get('name');
}
That fixed the share renaming (among other reference fixes) in mnemo,
which are going to be submitted soon. It's also the way Turba accesses
the shares.
correct source for the error and try to construct an example. I'll
reopen it once I know more.
http://www.php.net/manual/en/control-structures.foreach.php#66000
and changing the way the iteration works in that template fixed the
problem for me. But I don't know if that is dependant on the PHP
version. I am using PHP-5.1.6 on the development machine.
I can do further testing with the PHP version and also compare to the
datatree driver if that is required.
State ⇒ Feedback
references, they're not changed in either loop, and you should be able
to loop through it more than once. Is this a difference between the
kolab and datatree drivers, or a PHP version thing?
Priority ⇒ 1. Low
State ⇒ Unconfirmed
New Attachment: nag-templates-tasklists-tasklists.inc_foreach-with-references_20070308.patch
Queue ⇒ Nag
Summary ⇒ foreach with references in the tasklists.inc template
Type ⇒ Bug
list of references in my case (kolab share driver).
The use of the two foreach loops within the templates mixes up these
refernces and once I edit a share I end up with one shares being
listed twice and other shares missing.
In case the share array should really be an array of references the
attached patch would fix the problematic foreach loops. In case the
share list should not provide object references, the driver would
probably need to be modified accordingly.