Bug 122560 - Support OLD bugzilla installation O_o
git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1743 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
07d2f9841a
commit
5471194812
|
@ -123,38 +123,38 @@ sub handle_request
|
||||||
$ENV{$_} = $ENV{'HTTP_X_'.uc $_};
|
$ENV{$_} = $ENV{'HTTP_X_'.uc $_};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binmode STDOUT, ':utf8';
|
# Bugzilla-specific tweaks
|
||||||
|
binmode STDOUT, ':utf8' if Bugzilla->can('params') && Bugzilla->params->{utf8};
|
||||||
|
# Clear request cache for new versions
|
||||||
$Bugzilla::_request_cache = {};
|
$Bugzilla::_request_cache = {};
|
||||||
|
# Reload Bugzilla.pm for old versions on each request
|
||||||
|
my $preload = Bugzilla->can('request_cache') ? '' : "delete \$INC{'Bugzilla.pm'}; require 'Bugzilla.pm';";
|
||||||
# Use require() instead of sub caching under NYTProf profiler for more correct reports
|
# Use require() instead of sub caching under NYTProf profiler for more correct reports
|
||||||
|
my $content;
|
||||||
|
if ((!$subs{$script} || $ENV{NYTPROF} && $INC{'Devel/NYTProf.pm'}) && open $fd, "<$script")
|
||||||
|
{
|
||||||
|
local $/ = undef;
|
||||||
|
$content = <$fd>;
|
||||||
|
close $fd;
|
||||||
|
# untaint
|
||||||
|
($content) = $content =~ /^(.*)$/s;
|
||||||
|
}
|
||||||
if ($ENV{NYTPROF} && $INC{'Devel/NYTProf.pm'})
|
if ($ENV{NYTPROF} && $INC{'Devel/NYTProf.pm'})
|
||||||
{
|
{
|
||||||
my $start = [gettimeofday];
|
my $start = [gettimeofday];
|
||||||
delete $INC{$script};
|
eval "$preload package main; $content";
|
||||||
require $script;
|
|
||||||
my $elapsed = tv_interval($start) * 1000;
|
my $elapsed = tv_interval($start) * 1000;
|
||||||
print STDERR strftime("[%Y-%m-%d %H:%M:%S]", localtime)." Served $script via require() in $elapsed ms\n";
|
print STDERR strftime("[%Y-%m-%d %H:%M:%S]", localtime)." Served $script via require() in $elapsed ms\n";
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
# Simple "FastCGI" implementation - cache *.cgi in subs
|
# Simple "FastCGI" implementation - cache *.cgi in subs
|
||||||
if (!$subs{$script})
|
if (!$subs{$script} && $content)
|
||||||
{
|
{
|
||||||
my $content;
|
$subs{$script} = eval "package main; sub { $preload$content }";
|
||||||
if (open $fd, "<$script")
|
if ($@)
|
||||||
{
|
{
|
||||||
local $/ = undef;
|
warn "Error while loading $script:\n$@";
|
||||||
$content = <$fd>;
|
return 500;
|
||||||
close $fd;
|
|
||||||
# untaint
|
|
||||||
($content) = $content =~ /^(.*)$/s;
|
|
||||||
}
|
|
||||||
if ($content)
|
|
||||||
{
|
|
||||||
$subs{$script} = eval "sub { $content }";
|
|
||||||
if ($@)
|
|
||||||
{
|
|
||||||
warn "Error while loading $script:\n$@";
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Run cached sub
|
# Run cached sub
|
||||||
|
|
Loading…
Reference in New Issue