Skip to content

Commit dde80d9

Browse files
angavrilovgitster
authored andcommitted
gitweb: Fix mod_perl support.
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>
1 parent dd7f5f1 commit dde80d9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gitweb/gitweb.perl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BEGIN
3030
# if we're called with PATH_INFO, we have to strip that
3131
# from the URL to find our real URL
3232
# we make $path_info global because it's also used later on
33-
my $path_info = $ENV{"PATH_INFO"};
33+
our $path_info = $ENV{"PATH_INFO"};
3434
if ($path_info) {
3535
$my_url =~ s,\Q$path_info\E$,,;
3636
$my_uri =~ s,\Q$path_info\E$,,;
@@ -442,7 +442,7 @@ sub filter_snapshot_fmts {
442442
# together during validation: this allows subsequent uses (e.g. href()) to be
443443
# agnostic of the parameter origin
444444

445-
my %input_params = ();
445+
our %input_params = ();
446446

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

455-
my @cgi_param_mapping = (
455+
our @cgi_param_mapping = (
456456
project => "p",
457457
action => "a",
458458
file_name => "f",
@@ -469,10 +469,10 @@ sub filter_snapshot_fmts {
469469
extra_options => "opt",
470470
search_use_regexp => "sr",
471471
);
472-
my %cgi_param_mapping = @cgi_param_mapping;
472+
our %cgi_param_mapping = @cgi_param_mapping;
473473

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

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

0 commit comments

Comments
 (0)