From 69306f988a772fdc1a95a2775dbcbeb80fd86da0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Apr 2015 13:58:50 +0200 Subject: [PATCH] Bug 9006: Remove AUTOLOAD in C4::Context Happily this was only used for intranetdir. It's time to remove it and replace existing calls. I used the following commands to catch calls to C4::Context: git grep 'C4::Context\->' | grep -v 'C4::Context->preference' | grep -v 'C4::Context->config' | grep -v 'C4::Context->userenv' | grep -v 'C4::Context->IsSuperLibrarian' | grep -v 'C4::Context->dbh' | grep -v 'C4::Context->set_preference' | grep -v '_syspref_cache' | grep -v _userenv | grep -v 'C4::Context->interface' | grep -v 'C4::Context->Zconn' | grep -v 'C4::Context->queryparser' | grep -v 'C4::Context->tz' | grep -v 'C4::Context->boolean_preference' | grep -v 'C4::Context->memcached' --- C4/Context.pm | 18 ------------------ Koha/FrameworkPlugin.pm | 2 +- admin/auth_subfields_structure.pl | 4 ++-- admin/marc_subfields_structure.pl | 4 ++-- reports/manager.pl | 2 +- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 3e3f00c..456e68f 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -622,24 +622,6 @@ sub set_preference { } } -# AUTOLOAD -# This implements C4::Config->foo, and simply returns -# C4::Context->config("foo"), as described in the documentation for -# &config, above. - -# FIXME - Perhaps this should be extended to check &config first, and -# then &preference if that fails. OTOH, AUTOLOAD could lead to crappy -# code, so it'd probably be best to delete it altogether so as not to -# encourage people to use it. -sub AUTOLOAD -{ - my $self = shift; - - $AUTOLOAD =~ s/.*:://; # Chop off the package name, - # leaving only the function name. - return $self->config($AUTOLOAD); -} - =head2 Zconn $Zconn = C4::Context->Zconn diff --git a/Koha/FrameworkPlugin.pm b/Koha/FrameworkPlugin.pm index 39bb5ed..2d7390f 100644 --- a/Koha/FrameworkPlugin.pm +++ b/Koha/FrameworkPlugin.pm @@ -256,7 +256,7 @@ sub _load { } sub _valuebuilderpath { - return C4::Context->intranetdir . "/cataloguing/value_builder"; + return C4::Context->config('intranetdir') . "/cataloguing/value_builder"; #Formerly, intranetdir/cgi-bin was tested first. #But the intranetdir from koha-conf already includes cgi-bin for #package installs, single and standard installs. diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 3833b48..515a048 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -108,9 +108,9 @@ if ($op eq 'add_form') { # 2 cases here : on CVS install, $cgidir does not need a /cgi-bin # on a standard install, /cgi-bin need to be added. # test one, then the other - my $cgidir = C4::Context->intranetdir ."/cgi-bin"; + my $cgidir = C4::Context->config('intranetdir') ."/cgi-bin"; unless (opendir(DIR, "$cgidir/cataloguing/value_builder")) { - $cgidir = C4::Context->intranetdir; + $cgidir = C4::Context->config('intranetdir'); opendir(DIR, "$cgidir/cataloguing/value_builder") || die "can't opendir $cgidir/value_builder: $!"; } while (my $line = readdir(DIR)) { diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index c8b7815..5a7d356 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -154,9 +154,9 @@ if ( $op eq 'add_form' ) { # 2 cases here : on CVS install, $cgidir does not need a /cgi-bin # on a standard install, /cgi-bin need to be added. # test one, then the other - my $cgidir = C4::Context->intranetdir . "/cgi-bin"; + my $cgidir = C4::Context->config('intranetdir') . "/cgi-bin"; unless ( opendir( DIR, "$cgidir/cataloguing/value_builder" ) ) { - $cgidir = C4::Context->intranetdir; + $cgidir = C4::Context->config('intranetdir'); opendir( DIR, "$cgidir/cataloguing/value_builder" ) || die "can't opendir $cgidir/value_builder: $!"; } diff --git a/reports/manager.pl b/reports/manager.pl index e37da4f..43f4e71 100755 --- a/reports/manager.pl +++ b/reports/manager.pl @@ -44,7 +44,7 @@ $template->param(do_it => $do_it, ); my $cgidir = C4::Context->config('intranetdir')."/cgi-bin/reports/"; unless (-r $cgidir and -d $cgidir) { - $cgidir = C4::Context->intranetdir."/reports/"; + $cgidir = C4::Context->config('intranetdir')."/reports/"; } my $plugin = $cgidir.$report_name.".plugin"; require $plugin; -- 2.1.0