Bug 15702: Recommended Counter-patch

As per comment #7, this patch affects AddMember and ModMember.
The test plan should be the same as comment #6.
Secondary patch with tests still to come.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 7fd248f3e9)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Mark Tompsett 2017-01-19 21:13:47 -05:00 committed by Katrin Fischer
parent f3cf276c33
commit 1bbcf35772
1 changed files with 15 additions and 0 deletions

View File

@ -506,6 +506,14 @@ true on success, or false on failure
sub ModMember {
my (%data) = @_;
# trim whitespace from data which has some non-whitespace in it.
foreach my $field_name (keys(%data)) {
if ( defined $data{$field_name} && $data{$field_name} =~ /\S/ ) {
$data{$field_name} =~ s/^\s*|\s*$//g;
}
}
# test to know if you must update or not the borrower password
if (exists $data{password}) {
if ($data{password} eq '****' or $data{password} eq '') {
@ -594,6 +602,13 @@ sub AddMember {
my $dbh = C4::Context->dbh;
my $schema = Koha::Database->new()->schema;
# trim whitespace from data which has some non-whitespace in it.
foreach my $field_name (keys(%data)) {
if ( defined $data{$field_name} && $data{$field_name} =~ /\S/ ) {
$data{$field_name} =~ s/^\s*|\s*$//g;
}
}
# generate a proper login if none provided
$data{'userid'} = Generate_Userid( $data{'borrowernumber'}, $data{'firstname'}, $data{'surname'} )
if ( $data{'userid'} eq '' || !Check_Userid( $data{'userid'} ) );