Bugzilla – Attachment 157952 Details for
Bug 28410
[Omnibus] Reduce memory footprint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28410: remove Koha::Config::Syspref(s) from C4::Context
Bug-28410-remove-KohaConfigSysprefs-from-C4Context.patch (text/plain), 3.62 KB, created by
Blou
on 2023-10-26 20:07:30 UTC
(
hide
)
Description:
Bug 28410: remove Koha::Config::Syspref(s) from C4::Context
Filename:
MIME Type:
Creator:
Blou
Created:
2023-10-26 20:07:30 UTC
Size:
3.62 KB
patch
obsolete
>From 71841c58b9d7f359946802e3a565a7a706e7ba3d Mon Sep 17 00:00:00 2001 >From: Blou <blou@inlibro.com> >Date: Thu, 26 Oct 2023 13:52:54 -0400 >Subject: [PATCH] Bug 28410: remove Koha::Config::Syspref(s) from C4::Context > >Use straigth SQL queries to access systempreferences instead of relying >on the ORM, thus removing all direct and indirect dependencies to >Koha::Object >--- > C4/Context.pm | 43 +++++++++---------------------------------- > 1 file changed, 9 insertions(+), 34 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 0d8bce7458..712b3782a5 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -41,9 +41,8 @@ use File::Spec; > use List::MoreUtils qw(any); > > use Koha::Caches; >-use Koha::Config::SysPref; >-use Koha::Config::SysPrefs; > use Koha::Config; >+use Koha::Database; > use Koha; > > =head1 NAME >@@ -316,9 +315,7 @@ sub preference { > return $cached_var if defined $cached_var; > } > >- my $syspref; >- eval { $syspref = Koha::Config::SysPrefs->find( lc $var ) }; >- my $value = $syspref ? $syspref->value() : undef; >+ my ($value) = $self->dbh()->selectrow_array("SELECT value FROM systempreferences WHERE variable like '$var'"); > > if ( $use_syspref_cache ) { > my $syspref_cache = Koha::Caches->get_instance('syspref'); >@@ -430,10 +427,10 @@ sub set_preference { > my $variable_case = $variable; > $variable = lc $variable; > >- my $syspref = Koha::Config::SysPrefs->find($variable); >+ my ($oldvalue, $oldtype) = $self->dbh()->selectrow_array("SELECT value FROM systempreferences WHERE variable like '$variable'"); > $type = > $type ? $type >- : $syspref ? $syspref->type >+ : defined $oldtype ? $oldtype > : undef; > > $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); >@@ -443,31 +440,13 @@ sub set_preference { > $value = 'http://' . $value; > } > >- if ($syspref) { >- $syspref->set( >- { ( defined $value ? ( value => $value ) : () ), >- ( $explanation ? ( explanation => $explanation ) : () ), >- ( $type ? ( type => $type ) : () ), >- ( $options ? ( options => $options ) : () ), >- } >- )->store; >- } else { >- $syspref = Koha::Config::SysPref->new( >- { variable => $variable_case, >- value => $value, >- explanation => $explanation || undef, >- type => $type, >- options => $options || undef, >- } >- )->store(); >- } >+ $self->dbh()->do("INSERT INTO systempreferencesi (variable, value, explanation, type, options) values ($variable, $value, $explanation, $type, $options) ON DUPLICATE KEY UPDATE value = '$value'"); > > if ( $use_syspref_cache ) { > my $syspref_cache = Koha::Caches->get_instance('syspref'); > $syspref_cache->set_in_cache( "syspref_$variable", $value ); > } > >- return $syspref; > } > > =head2 delete_preference >@@ -483,15 +462,11 @@ was no syspref of the name. > sub delete_preference { > my ( $self, $var ) = @_; > >- if ( Koha::Config::SysPrefs->find( $var )->delete ) { >- if ( $use_syspref_cache ) { >- my $syspref_cache = Koha::Caches->get_instance('syspref'); >- $syspref_cache->clear_from_cache("syspref_$var"); >- } >- >- return 1; >+ my $rc = $self->dbh()->do("DELETE FROM systempreferences WHERE variable like '$var'"); >+ if ( $use_syspref_cache ) { >+ my $syspref_cache = Koha::Caches->get_instance('syspref'); >+ $syspref_cache->clear_from_cache("syspref_$var"); > } >- return 0; > } > > =head2 csv_delimiter >-- >2.34.1
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 28410
:
157875
|
157945
|
157946
|
157952
|
157953