Skip to content

Commit

Permalink
Bug 9006: Remove AUTOLOAD in C4::Context
Browse files Browse the repository at this point in the history
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'

NOTE: I applied 14428, and then did what I suggested in comment Koha-Community#2.
      Only intranetdir references appeared.

      I applied this patch, and repeated.
      Nothing appeared. This means the autoload references are
      properly removed.

      koha qa test tools complained about whitespace, I just fixed
      those. Though, we may wish to perltidy
      auth_fields_substructure.pl on another bug.

Signed-off-by: Mark Tompsett <[email protected]>

Signed-off-by: Kyle M Hall <[email protected]>
Signed-off-by: Tomas Cohen Arazi <[email protected]>
  • Loading branch information
joubu authored and tomascohen committed Jul 20, 2015
1 parent ea263a2 commit 454becb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
18 changes: 0 additions & 18 deletions C4/Context.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Koha/FrameworkPlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions admin/auth_subfields_structure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ sub auth_subfield_structure_exists {
# 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)) {
Expand Down
4 changes: 2 additions & 2 deletions admin/marc_subfields_structure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ sub marc_subfield_structure_exists {
# 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: $!";
}
Expand Down
2 changes: 1 addition & 1 deletion reports/manager.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
);
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;
Expand Down

0 comments on commit 454becb

Please sign in to comment.