From 6fa03f12adbf20d1b6d9225836585dc3887277b2 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 23 Jun 2016 14:51:26 -0400 Subject: [PATCH] Bug 16805: Log in with database admin user breaks OPAC MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit TEST PLAN --------- 1) Apply Jonathan's test patch 2) prove t/db_dependent/Letters.t -- dies before finishing tests 3) Apply second test patch 4) prove t/db_dependent/Letters.t -- dies before finishing tests -- 'addalert' is changed to 'getalert' 5) Log into OPAC with database admin user. -- see error given in comment #0 6) Apply this patch 7) prove t/db_dependent/Letters.t -- says 'getalert' -- all tests pass. 8) Log into OPAC with database admin user. -- logs in, but gives warning with a nice logout button. 9) run koha qa test tools. Signed-off-by: Hector Castro No kaha qa errors In debian display diferent error: Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/DBI.pm line 2054. Works as advertised NOTE: Revised test plan, as Jonathan added useful test case. Works as I've tested above. Hector tested older test plan which was steps 5,6,8 and 9. Revised test plan again while tweaking to address comment #9. Signed-off-by: Mark Tompsett Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit dee29d9f0b2b43bc762cb82a2212cd8a3d243f45) Signed-off-by: Frédéric Demians (cherry picked from commit e45ed6d2f477aa9a85750c0f7c2a4df1af50e94f) Signed-off-by: Julian Maurice --- C4/Letters.pm | 9 ++++----- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 12 ++++++++++++ opac/opac-user.pl | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 3aa5c37d9b..74da813caa 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -312,21 +312,20 @@ sub delalert { sub getalert { my ( $borrowernumber, $type, $externalid ) = @_; my $dbh = C4::Context->dbh; - my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE"; + my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE 1"; my @bind; if ($borrowernumber and $borrowernumber =~ /^\d+$/) { - $query .= " borrowernumber=? AND "; + $query .= " AND borrowernumber=?"; push @bind, $borrowernumber; } if ($type) { - $query .= " type=? AND "; + $query .= " AND type=?"; push @bind, $type; } if ($externalid) { - $query .= " externalid=? AND "; + $query .= " AND externalid=?"; push @bind, $externalid; } - $query =~ s/ AND $//; my $sth = $dbh->prepare($query); $sth->execute(@bind); return $sth->fetchall_arrayref({}); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 1f86b0d520..a1d7257fba 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -25,6 +25,18 @@
+ + [% IF adminWarning %] +
+

+ Warning: +Using this account is not recommended because some parts of Koha will not function as expected. Instead, please log in with a different account. + + Log out +

+
+ [% END %] + [% IF ( bor_messages ) %]

Messages for you

diff --git a/opac/opac-user.pl b/opac/opac-user.pl index fd4c480e2f..bfd666b718 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -77,6 +77,10 @@ my $canrenew = 1; $template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') ); +if (!$borrowernumber) { + $template->param( adminWarning => 1 ); +} + # get borrower information .... my ( $borr ) = GetMemberDetails( $borrowernumber ); -- 2.39.5