Bugzilla – Attachment 13473 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9066: VirtualShelves db access not Plack+MariaDB compatible
Bug-9066-VirtualShelves-db-access-not-PlackMariaDB.patch (text/plain), 5.08 KB, created by
Mason James
on 2012-11-16 05:09:42 UTC
(
hide
)
Description:
Bug 9066: VirtualShelves db access not Plack+MariaDB compatible
Filename:
MIME Type:
Creator:
Mason James
Created:
2012-11-16 05:09:42 UTC
Size:
5.08 KB
patch
obsolete
>From 3f06b2dee79b6f063902cf72686ed3c3ed07d1f5 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Tue, 13 Nov 2012 09:25:42 -0500 >Subject: [PATCH] Bug 9066: VirtualShelves db access not Plack+MariaDB compatible >Content-Type: text/plain; charset="utf-8" >http://koha-community.org > >The $dbh database handle in C4::VirtualShelves was declared at the >module level, which means under Plack it is initialized only once, when >the server first starts. With the default MySQL configuration this is >not a problem, since the MySQL connection does not time out, but the >MariaDB default configuration does time out, resulting in every page >that calls any sub in C4::VirtualShelves failing after a certain period. >This patch eliminates the module-level $dbh variable and replaces it >with $dbh handles in each subroutine that requires it. > >To test: >Confirm that Virtual Shelves functionality still works as expected. The >problem is not reproducible when using Apache or Plack+MySQL, but if >everything works after the patch has been applied, the changes are safe. > >http://bugs.koha-community.org/show_bug.cgi?id=6473 >--- > C4/VirtualShelves.pm | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 90a00a5..5682a15 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -50,8 +50,6 @@ BEGIN { > } > > >-my $dbh = C4::Context->dbh; >- > =head1 NAME > > C4::VirtualShelves - Functions for manipulating Koha virtual shelves >@@ -101,6 +99,7 @@ sub GetShelves { > my ($category, $row_count, $offset, $owner) = @_; > my @params; > my $total = _shelf_count($owner, $category); >+ my $dbh = C4::Context->dbh; > my $query = qq{ > SELECT vs.shelfnumber, vs.shelfname,vs.owner, > bo.surname,bo.firstname,vs.category,vs.sortfield, >@@ -155,6 +154,7 @@ the submitted parameters. > sub GetAllShelves { > my ($category,$owner,$adding_allowed) = @_; > my @params; >+ my $dbh = C4::Context->dbh; > my $query = 'SELECT vs.* FROM virtualshelves vs '; > if($category==1) { > $query.= qq{ >@@ -184,6 +184,7 @@ Returns shelf names and numbers for Add to combo of search results and Lists but > sub GetSomeShelfNames { > my ($owner, $purpose, $adding_allowed)= @_; > my ($bar, $pub, @params); >+ my $dbh = C4::Context->dbh; > > my $bquery = 'SELECT vs.shelfnumber, vs.shelfname FROM virtualshelves vs '; > my $limit= ShelvesMax($purpose); >@@ -223,6 +224,7 @@ Returns the above-mentioned fields for passed virtual shelf number. > > sub GetShelf { > my ($shelfnumber) = @_; >+ my $dbh = C4::Context->dbh; > my $query = qq( > SELECT shelfnumber, shelfname, owner, category, sortfield, > allow_add, allow_delete_own, allow_delete_other >@@ -306,6 +308,7 @@ Returns a code to know what's happen. > > sub AddShelf { > my ($hashref, $owner)= @_; >+ my $dbh = C4::Context->dbh; > > #initialize missing hash values to silence warnings > foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) { >@@ -343,6 +346,7 @@ C<$shelfnumber>, unless that bib is already on that shelf. > sub AddToShelf { > my ($biblionumber, $shelfnumber, $borrowernumber) = @_; > return unless $biblionumber; >+ my $dbh = C4::Context->dbh; > my $query = qq( > SELECT * > FROM virtualshelfcontents >@@ -382,6 +386,7 @@ Returns 1 if the action seemed to be successful. > > sub ModShelf { > my ($shelfnumber,$hashref) = @_; >+ my $dbh = C4::Context->dbh; > > my $query= "SELECT * FROM virtualshelves WHERE shelfnumber=?"; > my $sth = $dbh->prepare($query); >@@ -453,6 +458,7 @@ sub ShelfPossibleAction { > > return 0 unless defined($shelfnumber); > >+ my $dbh = C4::Context->dbh; > my $query = qq/ > SELECT IFNULL(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, IFNULL(sh.borrowernumber,0) AS borrowernumber > FROM virtualshelves vs >@@ -500,6 +506,7 @@ Returns 0 if no items have been deleted. > > sub DelFromShelf { > my ($bibref, $shelfnumber, $user) = @_; >+ my $dbh = C4::Context->dbh; > my $query = qq(SELECT allow_delete_own, allow_delete_other FROM virtualshelves WHERE shelfnumber=?); > my $sth= $dbh->prepare($query); > $sth->execute($shelfnumber); >@@ -544,6 +551,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); > } >@@ -629,6 +637,7 @@ sub _shelf_count { > my @params; > # Find out how many shelves total meet the submitted criteria... > >+ my $dbh = C4::Context->dbh; > my $query = "SELECT count(*) FROM virtualshelves vs "; > if($category==1) { > $query.= qq{ >@@ -661,6 +670,7 @@ sub _biblionumber_sth { #only used in obsolete sub below > sub _CheckShelfName { > my ($name, $cat, $owner, $number)= @_; > >+ my $dbh = C4::Context->dbh; > my $query = qq( > SELECT DISTINCT shelfnumber > FROM virtualshelves >-- >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 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568