Git development
 help / color / mirror / Atom feed
* [PATCH] gitweb: Fix mod_perl support.
@ 2008-11-05 22:10 Alexander Gavrilov
  2008-11-05 22:40 ` Jakub Narebski
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Gavrilov @ 2008-11-05 22:10 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Giuseppe Bilotta, Petr Baudis

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>
---
 gitweb/gitweb.perl |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c5254af..2174d4a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -30,7 +30,7 @@ our $my_uri = $cgi->url(-absolute => 1);
 # 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$,,;
@@ -436,7 +436,7 @@ $projects_list ||= $projectroot;
 # 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
@@ -446,7 +446,7 @@ my %input_params = ();
 # 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",
@@ -463,10 +463,10 @@ my @cgi_param_mapping = (
 	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,
@@ -498,7 +498,7 @@ my %actions = (
 
 # 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) ],
 );
 
-- 
tg: (933bb3a..) t/misc/mod-perl-fix (depends on: vanilla/master)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gitweb: Fix mod_perl support.
  2008-11-05 22:10 [PATCH] gitweb: Fix mod_perl support Alexander Gavrilov
@ 2008-11-05 22:40 ` Jakub Narebski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Narebski @ 2008-11-05 22:40 UTC (permalink / raw)
  To: Alexander Gavrilov; +Cc: git, Giuseppe Bilotta, Petr Baudis

Alexander Gavrilov wrote:

> [...] it is necessary to declare all global
> variables as 'our' [...]
> 
> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>

I have forgot about that when reviewing path_info patches. I'm sorry
about that. Good catch, and good explanation.

Acked-by: Jakub Narebski <jnareb@gmail.com>

> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index c5254af..2174d4a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
[...]

> -my $path_info = $ENV{"PATH_INFO"};
> +our $path_info = $ENV{"PATH_INFO"};
[...]

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-05 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-05 22:10 [PATCH] gitweb: Fix mod_perl support Alexander Gavrilov
2008-11-05 22:40 ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox