Skip to content

Commit

Permalink
gitweb: Fix mod_perl support.
Browse files Browse the repository at this point in the history
ModPerl::Registry precompiles scripts by wrapping them
in a subroutine. This causes ordinary subroutines of the
script to become nested, and warnings appear:

gitweb.cgi: Variable "$path_info" will not stay shared

This warning means that $path_info was declared as 'my',
and thus according to the perl evaluation rules all nested
subroutines will retain a reference to the instance of the
variable used in the first invocation of the master script.

When the script (i.e. the master meta-subroutine) is executed
the second time, it will use a new instance, so the logic
breaks. To avoid this it is necessary to declare all global
variables as 'our', which places them at the package level.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Alexander Gavrilov authored and Junio C Hamano committed Nov 7, 2008
1 parent dd7f5f1 commit dde80d9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BEGIN
# if we're called with PATH_INFO, we have to strip that
# from the URL to find our real URL
# we make $path_info global because it's also used later on
my $path_info = $ENV{"PATH_INFO"};
our $path_info = $ENV{"PATH_INFO"};
if ($path_info) {
$my_url =~ s,\Q$path_info\E$,,;
$my_uri =~ s,\Q$path_info\E$,,;
Expand Down Expand Up @@ -442,7 +442,7 @@ sub filter_snapshot_fmts {
# together during validation: this allows subsequent uses (e.g. href()) to be
# agnostic of the parameter origin

my %input_params = ();
our %input_params = ();

# input parameters are stored with the long parameter name as key. This will
# also be used in the href subroutine to convert parameters to their CGI
Expand All @@ -452,7 +452,7 @@ sub filter_snapshot_fmts {
# XXX: Warning: If you touch this, check the search form for updating,
# too.

my @cgi_param_mapping = (
our @cgi_param_mapping = (
project => "p",
action => "a",
file_name => "f",
Expand All @@ -469,10 +469,10 @@ sub filter_snapshot_fmts {
extra_options => "opt",
search_use_regexp => "sr",
);
my %cgi_param_mapping = @cgi_param_mapping;
our %cgi_param_mapping = @cgi_param_mapping;

# we will also need to know the possible actions, for validation
my %actions = (
our %actions = (
"blame" => \&git_blame,
"blobdiff" => \&git_blobdiff,
"blobdiff_plain" => \&git_blobdiff_plain,
Expand Down Expand Up @@ -504,7 +504,7 @@ sub filter_snapshot_fmts {

# finally, we have the hash of allowed extra_options for the commands that
# allow them
my %allowed_options = (
our %allowed_options = (
"--no-merges" => [ qw(rss atom log shortlog history) ],
);

Expand Down

0 comments on commit dde80d9

Please sign in to comment.