Commit 46317c31 authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 586244: Make mod_headers and mod_expires optional

r=glob, a=mkanat
parent 7df0160f
......@@ -2,14 +2,24 @@
<FilesMatch ^(.*\.pm|.*\.pl|.*localconfig.*)$>
deny from all
</FilesMatch>
<FilesMatch (\.js|\.css)$>
ExpiresActive On
# According to RFC 2616, "1 year in the future" means "never expire".
# We change the name of the file's URL whenever its modification date
# changes, so browsers can cache any individual JS or CSS URL forever.
# However, since all JS and CSS URLs involve a ? in them (for the changing
# name) we have to explicitly set an Expires header or browsers won't
# *ever* cache them.
ExpiresDefault "now plus 1 years"
Header append Cache-Control "public"
</FilesMatch>
<IfModule mod_expires.c>
<IfModule mod_headers.c>
<IfModule mod_env.c>
<FilesMatch (\.js|\.css)$>
ExpiresActive On
# According to RFC 2616, "1 year in the future" means "never expire".
# We change the name of the file's URL whenever its modification date
# changes, so browsers can cache any individual JS or CSS URL forever.
# However, since all JS and CSS URLs involve a ? in them (for the changing
# name) we have to explicitly set an Expires header or browsers won't
# *ever* cache them.
ExpiresDefault "now plus 1 years"
Header append Cache-Control "public"
</FilesMatch>
# This lets Bugzilla know that we are properly sending Cache-Control
# and Expires headers for CSS and JS files.
SetEnv BZ_CACHE_CONTROL 1
</IfModule>
</IfModule>
</IfModule>
......@@ -202,16 +202,19 @@ EOT
# And now check the version of the database server itself.
my $dbh = _get_no_db_connection();
printf("Checking for %15s %-9s ", $sql_server, "(v$sql_want)")
if $output;
my $sql_vers = $dbh->bz_server_version;
$dbh->disconnect;
my $version_ok = vers_cmp($sql_vers, $sql_want) > -1 ? 1 : 0;
if ($output) {
Bugzilla::Install::Requirements::_checking_for({
package => $sql_server, wanted => $sql_want,
found => $sql_vers, ok => $version_ok });
}
# Check what version of the database server is installed and let
# the user know if the version is too old to be used with Bugzilla.
if ( vers_cmp($sql_vers,$sql_want) > -1 ) {
print "ok: found v$sql_vers\n" if $output;
} else {
if (!$version_ok) {
die <<EOT;
Your $sql_server v$sql_vers is too old. Bugzilla requires version
......
......@@ -29,7 +29,9 @@ use strict;
use Bugzilla::Constants;
use Encode;
use ExtUtils::MM ();
use File::Basename;
use File::Spec;
use POSIX qw(setlocale LC_CTYPE);
use Safe;
use Scalar::Util qw(tainted);
......@@ -54,18 +56,19 @@ our @EXPORT_OK = qw(
);
sub bin_loc {
my ($bin) = @_;
return '' if ON_WINDOWS;
# Don't print any errors from "which"
open(my $saveerr, ">&STDERR");
open(STDERR, '>/dev/null');
my $loc = `which $bin`;
close(STDERR);
open(STDERR, ">&", $saveerr);
my $exit_code = $? >> 8; # See the perlvar manpage.
return '' if $exit_code > 0;
chomp($loc);
return $loc;
my ($bin, $path) = @_;
my @path = $path ? @$path : File::Spec->path;
foreach my $dir (@path) {
next if !-d $dir;
my $full_path = File::Spec->catfile($dir, $bin);
# MM is an alias for ExtUtils::MM. maybe_command is nice
# because it checks .com, .bat, .exe (etc.) on Windows.
my $command = MM->maybe_command($full_path);
return $command if $command;
}
return '';
}
sub get_version_and_os {
......
......@@ -399,10 +399,17 @@ sub multiline_sprintf {
sub _mtime { return (stat($_[0]))[9] }
sub mtime_filter {
my ($file_url) = @_;
my $cgi_path = bz_locations()->{'cgi_path'};
my $file_path = "$cgi_path/$file_url";
return "$file_url?" . _mtime($file_path);
my ($file_url, $mtime) = @_;
# This environment var is set in the .htaccess if we have mod_headers
# and mod_expires installed, to make sure that JS and CSS with "?"
# after them will still be cached by clients.
return $file_url if !$ENV{BZ_CACHE_CONTROL};
if (!$mtime) {
my $cgi_path = bz_locations()->{'cgi_path'};
my $file_path = "$cgi_path/$file_url";
$mtime = _mtime($file_path);
}
return "$file_url?$mtime";
}
# Set up the skin CSS cascade:
......@@ -453,8 +460,7 @@ sub css_files {
sub _css_link_set {
my ($file_name) = @_;
my $standard_mtime = _mtime($file_name);
my %set = (standard => $file_name . "?$standard_mtime");
my %set = (standard => mtime_filter($file_name));
# We use (^|/) to allow Extensions to use the skins system if they
# want.
......@@ -471,7 +477,7 @@ sub _css_link_set {
my $skin_file_name = $file_name;
$skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$option/};
if (my $mtime = _mtime("$cgi_path/$skin_file_name")) {
$skin_urls{$option} = $skin_file_name . "?$mtime";
$skin_urls{$option} = mtime_filter($skin_file_name, $mtime);
}
}
$set{alternate} = \%skin_urls;
......@@ -484,7 +490,7 @@ sub _css_link_set {
my $custom_file_name = $file_name;
$custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/};
if (my $custom_mtime = _mtime("$cgi_path/$custom_file_name")) {
$set{custom} = $custom_file_name . "?$custom_mtime";
$set{custom} = mtime_filter($custom_file_name, $custom_mtime);
}
return \%set;
......
......@@ -28,6 +28,11 @@
%strings = (
any => 'any',
apachectl_failed => <<END,
WARNING: We could not check the configuration of Apache. This sometimes
happens when you are not running checksetup.pl as ##root##. To see the
problem we ran into, run: ##command##
END
bad_executable => 'not a valid executable: ##bin##',
blacklisted => '(blacklisted)',
bz_schema_exists_before_220 => <<'END',
......@@ -260,6 +265,18 @@ EOT
# Note: When translating these "modules" messages, don't change the formatting
# if possible, because there is hardcoded formatting in
# Bugzilla::Install::Requirements to match the box formatting.
modules_message_apache => <<END,
***********************************************************************
* APACHE MODULES *
***********************************************************************
* Normally, when Bugzilla is upgraded, all Bugzilla users have to *
* clear their browser cache or Bugzilla will break. If you enable *
* certain modules in your Apache configuration (usually called *
* httpd.conf or apache2.conf) then your users will not have to clear *
* their caches when you upgrade Bugzilla. The modules you need to *
* enable are: *
* *
END
modules_message_db => <<EOT,
***********************************************************************
* DATABASE ACCESS *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment