{"thread":{"id":"16188","subject":"[PATCH] gitweb: Fix mod_perl support.","startedAt":"2008-11-05T22:10:07Z","lastAt":"2008-11-05T22:40:26Z","messageCount":2,"participants":["Alexander Gavrilov","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95004","messageId":"200811060110.07965.angavrilov@gmail.com","threadId":"16188","inReplyTo":null,"subject":"[PATCH] gitweb: Fix mod_perl support.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-11-05T22:10:07Z","receivedAt":"2008-11-05T22:10:07Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"ModPerl::Registry precompiles scripts by wrapping them\nin a subroutine. This causes ordinary subroutines of the\nscript to become nested, and warnings appear:\n\ngitweb.cgi: Variable \"$path_info\" will not stay shared\n\nThis warning means that $path_info was declared as 'my',\nand thus according to the perl evaluation rules all nested\nsubroutines will retain a reference to the instance of the\nvariable used in the first invocation of the master script.\n\nWhen the script (i.e. the master meta-subroutine) is executed\nthe second time, it will use a new instance, so the logic\nbreaks. To avoid this it is necessary to declare all global\nvariables as 'our', which places them at the package level.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n gitweb/gitweb.perl |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex c5254af..2174d4a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -30,7 +30,7 @@ our $my_uri = $cgi->url(-absolute => 1);\n # if we're called with PATH_INFO, we have to strip that\n # from the URL to find our real URL\n # we make $path_info global because it's also used later on\n-my $path_info = $ENV{\"PATH_INFO\"};\n+our $path_info = $ENV{\"PATH_INFO\"};\n if ($path_info) {\n \t$my_url =~ s,\\Q$path_info\\E$,,;\n \t$my_uri =~ s,\\Q$path_info\\E$,,;\n@@ -436,7 +436,7 @@ $projects_list ||= $projectroot;\n # together during validation: this allows subsequent uses (e.g. href()) to be\n # agnostic of the parameter origin\n \n-my %input_params = ();\n+our %input_params = ();\n \n # input parameters are stored with the long parameter name as key. This will\n # also be used in the href subroutine to convert parameters to their CGI\n@@ -446,7 +446,7 @@ my %input_params = ();\n # XXX: Warning: If you touch this, check the search form for updating,\n # too.\n \n-my @cgi_param_mapping = (\n+our @cgi_param_mapping = (\n \tproject => \"p\",\n \taction => \"a\",\n \tfile_name => \"f\",\n@@ -463,10 +463,10 @@ my @cgi_param_mapping = (\n \textra_options => \"opt\",\n \tsearch_use_regexp => \"sr\",\n );\n-my %cgi_param_mapping = @cgi_param_mapping;\n+our %cgi_param_mapping = @cgi_param_mapping;\n \n # we will also need to know the possible actions, for validation\n-my %actions = (\n+our %actions = (\n \t\"blame\" => \\&git_blame,\n \t\"blobdiff\" => \\&git_blobdiff,\n \t\"blobdiff_plain\" => \\&git_blobdiff_plain,\n@@ -498,7 +498,7 @@ my %actions = (\n \n # finally, we have the hash of allowed extra_options for the commands that\n # allow them\n-my %allowed_options = (\n+our %allowed_options = (\n \t\"--no-merges\" => [ qw(rss atom log shortlog history) ],\n );\n \n-- \ntg: (933bb3a..) t/misc/mod-perl-fix (depends on: vanilla/master)\n"},{"id":"95009","messageId":"200811052340.27677.jnareb@gmail.com","threadId":"16188","inReplyTo":"200811060110.07965.angavrilov@gmail.com","subject":"Re: [PATCH] gitweb: Fix mod_perl support.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-05T22:40:26Z","receivedAt":"2008-11-05T22:40:26Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Alexander Gavrilov wrote:\n\n> [...] it is necessary to declare all global\n> variables as 'our' [...]\n> \n> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n\nI have forgot about that when reviewing path_info patches. I'm sorry\nabout that. Good catch, and good explanation.\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index c5254af..2174d4a 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n[...]\n\n> -my $path_info = $ENV{\"PATH_INFO\"};\n> +our $path_info = $ENV{\"PATH_INFO\"};\n[...]\n\n-- \nJakub Narebski\nPoland\n"}]}