@matheusbsbs / matheus-bagliano / commits / dde80d9c23
Fork 0

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>

Alexander Gavrilov committed Nov 6, 2008 at 01:10 UTC dde80d9c23e10592817f0c81e32a99a889a9bb8e
1 file changed +6 -6
gitweb/gitweb.perl
+6 -6
@@ -30,7 +30,7 @@ our $my_uri = $cgi->url(-absolute => 1);
30 # if we're called with PATH_INFO, we have to strip that
31 # from the URL to find our real URL
32 # 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"};
34 if ($path_info) {
35 $my_url =~ s,\Q$path_info\E$,,;
36 $my_uri =~ s,\Q$path_info\E$,,;
@@ -442,7 +442,7 @@ $projects_list ||= $projectroot;
442 # together during validation: this allows subsequent uses (e.g. href()) to be
443 # agnostic of the parameter origin
444
445 -my %input_params = ();
445 +our %input_params = ();
446
447 # input parameters are stored with the long parameter name as key. This will
448 # also be used in the href subroutine to convert parameters to their CGI
@@ -452,7 +452,7 @@ my %input_params = ();
452 # XXX: Warning: If you touch this, check the search form for updating,
453 # too.
454
455 -my @cgi_param_mapping = (
455 +our @cgi_param_mapping = (
456 project => "p",
457 action => "a",
458 file_name => "f",
@@ -469,10 +469,10 @@ my @cgi_param_mapping = (
469 extra_options => "opt",
470 search_use_regexp => "sr",
471 );
472 -my %cgi_param_mapping = @cgi_param_mapping;
472 +our %cgi_param_mapping = @cgi_param_mapping;
473
474 # we will also need to know the possible actions, for validation
475 -my %actions = (
475 +our %actions = (
476 "blame" => \&git_blame,
477 "blobdiff" => \&git_blobdiff,
478 "blobdiff_plain" => \&git_blobdiff_plain,
@@ -504,7 +504,7 @@ my %actions = (
504
505 # finally, we have the hash of allowed extra_options for the commands that
506 # allow them
507 -my %allowed_options = (
507 +our %allowed_options = (
508 "--no-merges" => [ qw(rss atom log shortlog history) ],
509 );
510