Bugzilla – Attachment 8531 Details for
Bug 7796
C4/VirtualShelves.pm needs globally scoped $dbh for plack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7796 - C4/VirtualShelves.pm $dbh plack scoping
Bug-7796---C4VirtualShelvespm-dbh-plack-scoping.patch (text/plain), 4.22 KB, created by
Dobrica Pavlinusic
on 2012-03-22 16:09:10 UTC
(
hide
)
Description:
Bug 7796 - C4/VirtualShelves.pm $dbh plack scoping
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2012-03-22 16:09:10 UTC
Size:
4.22 KB
patch
obsolete
>From 24b8f48354c79d7bc31b10f8cc76c1f2feba2ed3 Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Thu, 22 Mar 2012 12:19:55 +0100 >Subject: [PATCH] Bug 7796 - C4/VirtualShelves.pm $dbh plack scoping > >we get a lot of "MySQL server has gone away" error messages and >defining global $dbh isn't the best solution. Existing code >gets $dbh from context in some subs, so this change makes it always >use $dbh from context. >--- > C4/VirtualShelves.pm | 15 +++++++++++++-- > 1 files changed, 13 insertions(+), 2 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 85dbc9f..2091c7a 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -54,8 +54,6 @@ BEGIN { > } > > >-my $dbh = C4::Context->dbh; >- > =head1 NAME > > C4::VirtualShelves - Functions for manipulating Koha virtual shelves >@@ -128,6 +126,7 @@ sub GetShelves { > ORDER BY vs.shelfname > LIMIT ?, ?}; > >+ my $dbh = C4::Context->dbh; > my $sth2 = $dbh->prepare($query); > $sth2->execute(@params); > my %shelflist; >@@ -174,6 +173,7 @@ sub GetAllShelves { > $query.='AND (allow_add=1 OR owner=?) ' if $adding_allowed; > push @params, $owner if $adding_allowed; > $query.= 'ORDER BY shelfname ASC'; >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( $query ); > $sth->execute(@params); > return $sth->fetchall_arrayref({}); >@@ -197,6 +197,8 @@ sub GetSomeShelfNames { > push @params, $owner||0 if $adding_allowed; > $qry1.= "ORDER BY vs.lastmodified DESC LIMIT $limit"; > >+ my $dbh = C4::Context->dbh; >+ > unless($adding_allowed && (!defined($owner) || $owner<=0)) { > #if adding items, user should be known > $pub= $dbh->selectall_arrayref($qry1,{Slice=>{}},@params); >@@ -235,6 +237,7 @@ sub GetShelf ($) { > FROM virtualshelves > WHERE shelfnumber=? > ); >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute($shelfnumber); > return $sth->fetchrow; >@@ -324,6 +327,7 @@ sub AddShelf { > (shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other) > VALUES (?,?,?,?,?,?,?)); > >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute( > $hashref->{shelfname}, >@@ -354,6 +358,7 @@ sub AddToShelf { > FROM virtualshelfcontents > WHERE shelfnumber=? AND biblionumber=? > ); >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > > $sth->execute( $shelfnumber, $biblionumber ); >@@ -390,6 +395,7 @@ sub ModShelf { > my ($shelfnumber,$hashref) = @_; > > my $query= "SELECT * FROM virtualshelves WHERE shelfnumber=?"; >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute($shelfnumber); > my $oldrecord= $sth->fetchrow_hashref; >@@ -465,6 +471,7 @@ sub ShelfPossibleAction { > AND sh.borrowernumber=? > WHERE vs.shelfnumber=? > /; >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute($user, $shelfnumber); > my $shelf= $sth->fetchrow_hashref; >@@ -506,6 +513,7 @@ Returns 0 if no items have been deleted. > sub DelFromShelf { > my ($bibref, $shelfnumber, $user) = @_; > my $query = qq(SELECT allow_delete_own, allow_delete_other FROM virtualshelves WHERE shelfnumber=?); >+ my $dbh = C4::Context->dbh; > my $sth= $dbh->prepare($query); > $sth->execute($shelfnumber); > my ($del_own, $del_oth)= $sth->fetchrow; >@@ -549,6 +557,7 @@ ShelfPossibleAction with manage parameter. > sub DelShelf { > my ($shelfnumber)= @_; > return unless $shelfnumber && $shelfnumber =~ /^\d+$/; >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare("DELETE FROM virtualshelves WHERE shelfnumber=?"); > return $sth->execute($shelfnumber); > } >@@ -646,6 +655,7 @@ sub _shelf_count { > $query.='WHERE category=2'; > @params= (); > } >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute(@params); > my ($total)= $sth->fetchrow; >@@ -686,6 +696,7 @@ sub _CheckShelfName { > else { > $query.= ' AND category=2'; > } >+ my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); > $sth->execute($cat==1? ($name, $number, $owner, $owner): ($name, $number)); > return $sth->rows>0? 0: 1; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7796
:
8499
| 8531