@@ -, +, @@ to using SQL query. --- 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(-) --- a/C4/Context.pm +++ a/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 --- a/Koha/Config/SysPref.pm +++ a/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 --- a/admin/preferences.pl +++ a/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'}; --- a/t/db_dependent/sysprefs.t +++ a/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; --