Bug 10033 - dangerous query in _koha_modify_item
authorFridolyn SOMERS <fridolyn.somers@biblibre.com>
Fri, 12 Apr 2013 15:24:17 +0000 (17:24 +0200)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 1 May 2013 12:17:03 +0000 (08:17 -0400)
commit598dfe27224f517fafa06df75521c623992ecbe0
treec3fdba58471c86747d84165a968dccf611a1eb23
parentb7d0c50487bb6388b9d90a8ea71313730af931d9
Bug 10033 - dangerous query in _koha_modify_item

The SQL query build in C4::Items::_koha_modify_item performs an update on a row of items table identified by itemnumber.
Actually the query is build using a hash of datas :
    for my $key ( keys %$item ) {
        $query.="$key=?,";
        push @bind, $item->{$key};
    }
But this hash contains 'itemnumber' key, so you get an update including the primary key.
It is actually harmless but may be dangerous.

This patch simply skips itemnumber key in above loop.

Test plan :
Check you can create and modify items.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/Items.pm