[Koha-patches] [PATCH] CORRECTION: fixes print statements with missing 'STDERR',
Mason James
mason.loves.sushi at gmail.com
Sun Mar 8 13:31:10 CET 2009
err, the 'warn sprintf()'s still actually output to STDOUT :/
this patch fixes that.
---
C4/Auth_with_ldap.pm | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index c286275..396c768 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -91,11 +91,11 @@ sub checkpw_ldap {
) or die "LDAP search failed to return object.";
my $count = $search->count;
if ($search->code > 0) {
- warn sprintf("LDAP Auth rejected : %s gets %d hits\n", $filter->as_string, $count) . description($search);
+ print STDERR sprintf("LDAP Auth rejected : %s gets %d hits\n", $filter->as_string, $count) . description($search);
return 0;
}
if ($count != 1) {
- warn sprintf("LDAP Auth rejected : %s gets %d hits\n", $filter->as_string, $count);
+ print STDERR sprintf("LDAP Auth rejected : %s gets %d hits\n", $filter->as_string, $count);
return 0;
}
@@ -109,7 +109,7 @@ sub checkpw_ldap {
return 1;
}
my %borrower = ldap_entry_2_hash($userldapentry,$userid);
- $debug and print "checkpw_ldap received \%borrower w/ " . keys(%borrower), " keys: ", join(' ', keys %borrower), "\n";
+ $debug and warn "checkpw_ldap received \%borrower w/ " . keys(%borrower), " keys: ", join(' ', keys %borrower), "\n";
my ($borrowernumber,$cardnumber,$savedpw);
($borrowernumber,$cardnumber,$userid,$savedpw) = exists_local($userid);
if ($borrowernumber) {
@@ -132,9 +132,9 @@ sub ldap_entry_2_hash ($$) {
my %memberhash;
$userldapentry->exists('uid'); # This is bad, but required! By side-effect, this initializes the attrs hash.
if ($debug) {
- print "\nkeys(\%\$userldapentry) = " . join(', ', keys %$userldapentry), "\n", $userldapentry->dump();
+ warn "\nkeys(\%\$userldapentry) = " . join(', ', keys %$userldapentry), "\n", $userldapentry->dump();
foreach (keys %$userldapentry) {
- print "\n\nLDAP key: $_\t", sprintf('(%s)', ref $userldapentry->{$_}), "\n";
+ print STDERR "\n\nLDAP key: $_\t", sprintf('(%s)', ref $userldapentry->{$_}), "\n";
hashdump("LDAP key: ",$userldapentry->{$_});
}
}
@@ -142,13 +142,13 @@ sub ldap_entry_2_hash ($$) {
my $key;
foreach (keys %$x) {
$memberhash{$_} = join ' ', @{$x->{$_}};
- $debug and print sprintf("building \$memberhash{%s} = ", $_, join(' ', @{$x->{$_}})), "\n";
+ $debug and print STDERR sprintf("building \$memberhash{%s} = ", $_, join(' ', @{$x->{$_}})), "\n";
}
$debug and print "Finsihed \%memberhash has ", scalar(keys %memberhash), " keys\n",
"Referencing \%mapping with ", scalar(keys %mapping), " keys\n";
foreach my $key (keys %mapping) {
my $data = $memberhash{$mapping{$key}->{is}};
- $debug and printf "mapping %20s ==> %-20s (%s)\n", $key, $mapping{$key}->{is}, $data;
+ $debug and printf STDERR "mapping %20s ==> %-20s (%s)\n", $key, $mapping{$key}->{is}, $data;
unless (defined $data) {
$data = $mapping{$key}->{content} || ''; # default or failsafe ''
}
@@ -168,12 +168,12 @@ sub exists_local($) {
my $sth = $dbh->prepare("$select WHERE userid=?"); # was cardnumber=?
$sth->execute($arg);
- $debug and printf "Userid '$arg' exists_local? %s\n", $sth->rows;
+ $debug and printf STDERR "Userid '$arg' exists_local? %s\n", $sth->rows;
($sth->rows == 1) and return $sth->fetchrow;
$sth = $dbh->prepare("$select WHERE cardnumber=?");
$sth->execute($arg);
- $debug and printf "Cardnumber '$arg' exists_local? %s\n", $sth->rows;
+ $debug and printf STDERR "Cardnumber '$arg' exists_local? %s\n", $sth->rows;
($sth->rows == 1) and return $sth->fetchrow;
return 0;
}
@@ -200,7 +200,7 @@ sub update_local($$$$) {
# MODIFY PASSWORD/LOGIN
# search borrowerid
- $debug and print "changing local password for borrowernumber=$borrowerid to '$digest'\n";
+ $debug and warn "changing local password for borrowernumber=$borrowerid to '$digest'\n";
changepassword($userid, $borrowerid, $digest);
# Confirm changes
--
1.5.6.5
More information about the Koha-patches
mailing list