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-67ecbb4d7f56
master
vfilippov 2013-07-25 16:10:09 +00:00
parent 07d2f9841a
commit 5471194812
1 changed files with 20 additions and 20 deletions

View File

@ -123,38 +123,38 @@ sub handle_request
$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 = {};
# 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
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'})
{
my $start = [gettimeofday];
delete $INC{$script};
require $script;
eval "$preload package main; $content";
my $elapsed = tv_interval($start) * 1000;
print STDERR strftime("[%Y-%m-%d %H:%M:%S]", localtime)." Served $script via require() in $elapsed ms\n";
return 200;
}
# Simple "FastCGI" implementation - cache *.cgi in subs
if (!$subs{$script})
if (!$subs{$script} && $content)
{
my $content;
if (open $fd, "<$script")
$subs{$script} = eval "package main; sub { $preload$content }";
if ($@)
{
local $/ = undef;
$content = <$fd>;
close $fd;
# untaint
($content) = $content =~ /^(.*)$/s;
}
if ($content)
{
$subs{$script} = eval "sub { $content }";
if ($@)
{
warn "Error while loading $script:\n$@";
return 500;
}
warn "Error while loading $script:\n$@";
return 500;
}
}
# Run cached sub