Bug 30649: (follow-up) Improve database update
This patch implements the proposed switch to use the standard DB handle and only require Koha::Encryption if necessary. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> (cherry picked from commitf8d2291f2e
) Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> (cherry picked from commitf742b2a84a
) Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
67d27898df
commit
86ecefe829
1 changed files with 12 additions and 11 deletions
|
@ -10,16 +10,17 @@ return {
|
||||||
ALTER TABLE vendor_edi_accounts CHANGE COLUMN `password` `password` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
ALTER TABLE vendor_edi_accounts CHANGE COLUMN `password` `password` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||||
});
|
});
|
||||||
|
|
||||||
|
my $edi_vendors =
|
||||||
|
$dbh->selectall_arrayref( "SELECT * FROM vendor_edit_accounts", { Slice => {} } );
|
||||||
|
if (@$edi_vendors) {
|
||||||
require Koha::Encryption;
|
require Koha::Encryption;
|
||||||
my $e = Koha::Encryption->new;
|
my $e = Koha::Encryption->new;
|
||||||
|
for my $edi_vendor (@$edi_vendors) {
|
||||||
my $schema = Koha::Database->new()->schema();
|
my $id = $edi_vendor->{id};
|
||||||
my $rs = $schema->resultset('VendorEdiAccount')->search();
|
my $password = $edi_vendor->{password};
|
||||||
while ( my $a = $rs->next() ) {
|
|
||||||
my $password = $a->password;
|
|
||||||
$password = $e->encrypt_hex($password);
|
$password = $e->encrypt_hex($password);
|
||||||
$a->password($password);
|
$dbh->do("UPDATE edi_vendor_accounts SET password = $password WHERE id = $id");
|
||||||
$a->update();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue