Bugzilla – Attachment 62518 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 - Fixed intranet-error log error, by changing back to using SQL query.
Bug-18291---Fixed-intranet-error-log-error-by-chan.patch (text/plain), 3.81 KB, created by
Marc Véron
on 2017-04-21 06:44:56 UTC
(
hide
)
Description:
Bug 18291 - Fixed intranet-error log error, by changing back to using SQL query.
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-04-21 06:44:56 UTC
Size:
3.81 KB
patch
obsolete
>From bfb77e4cdf2bb2bc8fe185ab440f41330c399442 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Sat, 18 Mar 2017 00:59:50 +0000 >Subject: [PATCH] Bug 18291 - Fixed intranet-error log error, by changing back > to using SQL query. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Removed select_systempreferences subroutine from C4::Context.pm > >The subroutine in Koha::Config::SysPref.pm includes a successful unit test and POD > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Context.pm | 13 ------------- > Koha/Config/SysPref.pm | 13 +++++-------- > admin/preferences.pl | 2 +- > t/db_dependent/sysprefs.t | 11 ++++------- > 4 files changed, 10 insertions(+), 29 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index d3d57f1..a50ddfd 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -559,19 +559,6 @@ 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 785bc43..54011cd 100644 >--- a/Koha/Config/SysPref.pm >+++ b/Koha/Config/SysPref.pm >@@ -68,19 +68,16 @@ sub delete { > } > > =head3 select_systempreferences >-my $row = Koha::Config::SysPrefs->find($name); >+my $row = Koha::Config::SysPref->select_systempreferences($name); > >-This subroutine retrieves systempreference records with a specific variable value >+This subroutine retrieves the value and type values for 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; >- >+ my $dbh = C4::Context->dbh; >+ my $row = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name ); >+ return $row; > } > > =head3 type >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 5c0623a..b776b3f 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -158,7 +158,7 @@ sub TransformPrefsToHTML { > my $name = $piece->{'pref'}; > > if ( $name ) { >- my $row = C4::Context->select_systempreferences($name); >+ my $row = Koha::Config::SysPref->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/sysprefs.t b/t/db_dependent/sysprefs.t >index 98d0c92..58aea5b 100755 >--- a/t/db_dependent/sysprefs.t >+++ b/t/db_dependent/sysprefs.t >@@ -63,16 +63,13 @@ 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 $dbh = C4::Context->dbh; >+ my $sth = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name ); >+ return $sth; > } > >- > my $syspref = select_systempreferences('OPACHEADER'); >-is( $syspref, 1, 'correct number of syspref found'); >+is( $syspref->{'type'}, "Textarea", '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