[Koha-bugs] [Bug 11184] Fix wrong attribute type cloning

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Mar 24 05:31:08 CET 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11184

--- Comment #5 from M. Tompsett <mtompset at hotmail.com> ---
The fix:
    my $newentry = { %$entry };
takes the hash and generates a copy. This is what:
    my $newentry = { map { $_ => $entry->{$_} } %$entry };
is supposed to do, but it does it wrong.

It could be fixed by making it:
    my $newentry = { map { $_ => $entry->{$_} } keys %$entry };
However, mapping and access functions to copy are much likely to be slower than
just straight copying.

Instead of copying
    { k1 => v1, k2 => v2, ..., kn => vn }
The broken code generates
    { k1 => v1, v1 => undef, k2 => v2, v2 => undef, ... kn => vn, vn => undef }
This can create some weird errors if the value of any of those keys is undef.
This is also twice the size of the hash.

And yes, this fix should be applied to the other line as well.

Hope this clarifies, Katrin.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list