Bugzilla – Attachment 59633 Details for
Bug 17955
Remove the sql code and unnecessary use pragmas from the onboarding.pl script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17955 - Implemented working DBIX in place of sql queries throughout the whole of the onboarding.pl script.
Bug-17955---Implemented-working-DBIX-in-place-of-s.patch (text/plain), 6.19 KB, created by
Alex Buckley
on 2017-01-29 20:07:05 UTC
(
hide
)
Description:
Bug 17955 - Implemented working DBIX in place of sql queries throughout the whole of the onboarding.pl script.
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-01-29 20:07:05 UTC
Size:
6.19 KB
patch
obsolete
>From 91e26de91866bd1475adf5f67638d398a820def9 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 30 Jan 2017 08:59:42 +1300 >Subject: [PATCH] Bug 17955 - Implemented working DBIX in place of sql queries > throughout the whole of the onboarding.pl script. > >Modified the onshelfholds if statement logic in the onboarding.pl >script. > >Removed unneccisary use pragmas from onboarding.pl script >--- > installer/onboarding.pl | 103 ++++++++---------------------------------------- > 1 file changed, 17 insertions(+), 86 deletions(-) > >diff --git a/installer/onboarding.pl b/installer/onboarding.pl >index 07aea3b..3b05342 100755 >--- a/installer/onboarding.pl >+++ b/installer/onboarding.pl >@@ -82,7 +82,7 @@ my $dbh = DBI->connect( > ); > > #Store the value of the template input name='op' in the variable $op so we can check if the user has pressed the button with the name="op" and value="finish" meaning the user has finished the onboarding tool. >-my $op = $input->param('op'); >+my $op = $input->param('op') || ''; > $template->param( 'op' => $op ); > > my $schema = Koha::Database->new()->schema(); >@@ -277,10 +277,6 @@ elsif ( $step && $step == 3 ) { > > my $existing_cardnumber = $schema->resultset('Borrower')->get_column('cardnumber')->max(); > >- warn $existing_cardnumber; >- >-#my $exisiting_cardnumber = my $sth_search = >-# $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); > my $new_cardnumber = $existing_cardnumber + 1; > $template->param( "newcardnumber" => $new_cardnumber ); > >@@ -563,98 +559,33 @@ elsif ( $step && $step == 5 ) { > > my @messages; > >-#New code from smart-rules.tt starts here. Needs to be added to library > #Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. > if ( $branch eq "*" ) { > my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); >-# my $sth_search = $dbh->prepare( >-# "SELECT count(*) AS total >-# FROM default_circ_rules" >-# ); >-# my $sth_insert = $dbh->prepare( >-# "INSERT INTO default_circ_rules >-# (maxissueqty, onshelfholds) >-# VALUES (?, ?)" >-# ); >-# my $sth_update = $dbh->prepare( >-# "UPDATE default_circ_rules >-# SET maxissueqty = ?, onshelfholds = ?" >-# ); >- >- >-# my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); >-# warn $search_default_rules; >- >-# my $res = $search_default_rules->fetchrow_hashref(); >-# if ( $res->{total} ) { >-# $sth_update->execute( $maxissueqty, $onshelfholds ); >- >-# my $update_default_rules = $schema->resultset('DefaultCircrule')->set({maxissueqty => $maxissueqty}, {onshelfholds => $onshelfholds }); >-# } >-# else { >-# $sth_insert->execute( $maxissueqty, $onshelfholds ); >- my $insert_default_rules = $schema->resultset('Issuingrule')->set([ >- { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }, >- ]); >-# } >+ my $insert_default_rules = $schema->resultset('Issuingrule')->new( >+ { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds } >+ ); > } >- > #Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to. >- if ( $bor eq "*" ) { >- my $sth_search = $dbh->prepare( >- "SELECT count(*) AS total >- FROM default_circ_rules" >- ); >- my $sth_insert = $dbh->prepare( >- q| >- INSERT INTO default_circ_rules >- (maxissueqty) >- VALUES (?) >- | >- ); >- my $sth_update = $dbh->prepare( >- q| >- UPDATE default_circ_rules >- SET maxissueqty = ? >- | >- ); >+ elsif ( $bor eq "*" ) { > >- $sth_search->execute(); >- my $res = $sth_search->fetchrow_hashref(); >- if ( $res->{total} ) { >- $sth_update->execute($maxissueqty); >- } >- else { >- $sth_insert->execute($maxissueqty); >- } >+ my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); >+ my $insert_default_rules = $schema->resultset('Issuingrule')->new( >+ { maxissueqty => $maxissueqty} >+ ); > } > > #Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to >- if ( $itemtype eq "*" ) { >- my $sth_search = $dbh->prepare( >- "SELECT count(*) AS total >- FROM default_branch_circ_rules >- WHERE branchcode = ?" >- ); >- my $sth_insert = $dbh->prepare( >- "INSERT INTO default_branch_circ_rules >- (branchcode, onshelfholds) >- VALUES (?, ?)" >- ); >- my $sth_update = $dbh->prepare( >- "UPDATE default_branch_circ_rules >- SET onshelfholds = ? >- WHERE branchcode = ?" >+ elsif ( $itemtype eq "*" ) { >+ my $search_default_rules = $schema->resultset('DefaultCircRule')->search({},{ >+ branchcode => $branch >+ } >+ > ); >- $sth_search->execute($branch); >- my $res = $sth_search->fetchrow_hashref(); > >- if ( $res->{total} ) { >- $sth_update->execute( $onshelfholds, $branch ); >- } >- else { >- $sth_insert->execute( $branch, $onshelfholds ); >- } >+ my $insert_default_rules = $schema->resultset('Issuingrule')->new( >+ { branchcode => $branch, onshelfholds => $onshelfholds } >+ ); > } > > my $issuingrule = Koha::IssuingRules->find( >-- >2.1.4
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 17955
:
59633
|
59634
|
59636
|
59639