Bugzilla – Attachment 61235 Details for
Bug 18291
Remove SQL from preferences.pl administrative script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18291 - Removed the SQL query out of admin/preferences.pl
Bug-18291---Removed-the-SQL-query-out-of-adminpref.patch (text/plain), 3.85 KB, created by
Alex Buckley
on 2017-03-18 01:10:52 UTC
(
hide
)
Description:
Bug 18291 - Removed the SQL query out of admin/preferences.pl
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-03-18 01:10:52 UTC
Size:
3.85 KB
patch
obsolete
>From 5107ce2fd803dcbb60292bcafec102903c192cd4 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 17 Mar 2017 23:54:02 +0000 >Subject: [PATCH] Bug 18291 - Removed the SQL query out of admin/preferences.pl > >Placed a subroutine into Context.pm which in turn calls >Koha::Config::SysPref.pm where the SQL query has been re-written as a >DBIx query >--- > C4/Context.pm | 13 +++++++++++++ > Koha/Config/SysPref.pm | 16 ++++++++++++++++ > admin/preferences.pl | 2 +- > t/db_dependent/Context.t | 1 - > t/db_dependent/sysprefs.t | 17 ++++++++++++++++- > 5 files changed, 46 insertions(+), 3 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index a50ddfd..d3d57f1 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -559,6 +559,19 @@ sub delete_preference { > return 0; > } > >+=head2 select_systempreferences >+my $row = C4::Context->select_systempreferences($name); >+ >+This subroutine retrieves and returns the value and type of systempreference records matching the variable value $name >+=cut >+ >+sub select_systempreferences { >+ my ($self, $name) = @_; >+ my $row = Koha::Config::SysPrefs->find($name); >+ return $row; >+} >+ >+ > =head2 Zconn > > $Zconn = C4::Context->Zconn >diff --git a/Koha/Config/SysPref.pm b/Koha/Config/SysPref.pm >index 1e71b8c..785bc43 100644 >--- a/Koha/Config/SysPref.pm >+++ b/Koha/Config/SysPref.pm >@@ -67,6 +67,22 @@ sub delete { > return $deleted; > } > >+=head3 select_systempreferences >+my $row = Koha::Config::SysPrefs->find($name); >+ >+This subroutine retrieves systempreference records with a specific variable value >+=cut >+ >+sub select_systempreferences { >+ my ($self, $name) = @_; >+ my $schema = Koha::Database->new()->schema(); >+ my $syspref = $schema->resultset('Systempreference')->search( >+ {variable => $name} >+ ); >+ return $syspref; >+ >+} >+ > =head3 type > > =cut >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 032789f..5c0623a 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -158,7 +158,7 @@ sub TransformPrefsToHTML { > my $name = $piece->{'pref'}; > > if ( $name ) { >- my $row = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name ); >+ my $row = C4::Context->select_systempreferences($name); > my $value; > if ( ( !defined( $row ) || ( !defined( $row->{'value'} ) && $row->{'type'} ne 'YesNo' ) ) && defined( $piece->{'default'} ) ) { > $value = $piece->{'default'}; >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index bce0cef..b848579 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -7,7 +7,6 @@ use Test::More; > use Test::MockModule; > use vars qw($debug $koha $dbh $config $ret); > use t::lib::Mocks; >- > use Koha::Database; > > BEGIN { >diff --git a/t/db_dependent/sysprefs.t b/t/db_dependent/sysprefs.t >index 340e89a..98d0c92 100755 >--- a/t/db_dependent/sysprefs.t >+++ b/t/db_dependent/sysprefs.t >@@ -19,8 +19,9 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 8; >+use Test::More tests => 9; > use C4::Context; >+use Koha::Database; > > # Start transaction > my $dbh = C4::Context->dbh; >@@ -60,4 +61,18 @@ is(C4::Context->preference('testpreference'), 'def', 'caching preferences'); > C4::Context->clear_syspref_cache(); > is(C4::Context->preference('testpreference'), undef, 'clearing preference cache'); > >+sub select_systempreferences { >+ my ($name) = @_; >+ my $schema = Koha::Database->new()->schema(); >+ my $syspref = $schema->resultset('Systempreference')->search( >+ {variable => $name} >+ ); >+ return $syspref; >+} >+ >+ >+my $syspref = select_systempreferences('OPACHEADER'); >+is( $syspref, 1, 'correct number of syspref found'); >+ >+ > $dbh->rollback; >-- >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 18291
:
61235
|
61236
|
62517
|
62518
|
62905
|
62906