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 @@ ...@@ -2,14 +2,24 @@
<FilesMatch ^(.*\.pm|.*\.pl|.*localconfig.*)$> <FilesMatch ^(.*\.pm|.*\.pl|.*localconfig.*)$>
deny from all deny from all
</FilesMatch> </FilesMatch>
<FilesMatch (\.js|\.css)$> <IfModule mod_expires.c>
ExpiresActive On <IfModule mod_headers.c>
# According to RFC 2616, "1 year in the future" means "never expire". <IfModule mod_env.c>
# We change the name of the file's URL whenever its modification date <FilesMatch (\.js|\.css)$>
# changes, so browsers can cache any individual JS or CSS URL forever. ExpiresActive On
# However, since all JS and CSS URLs involve a ? in them (for the changing # According to RFC 2616, "1 year in the future" means "never expire".
# name) we have to explicitly set an Expires header or browsers won't # We change the name of the file's URL whenever its modification date
# *ever* cache them. # changes, so browsers can cache any individual JS or CSS URL forever.
ExpiresDefault "now plus 1 years" # However, since all JS and CSS URLs involve a ? in them (for the changing
Header append Cache-Control "public" # name) we have to explicitly set an Expires header or browsers won't
</FilesMatch> # *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 ...@@ -202,16 +202,19 @@ EOT
# And now check the version of the database server itself. # And now check the version of the database server itself.
my $dbh = _get_no_db_connection(); 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; my $sql_vers = $dbh->bz_server_version;
$dbh->disconnect; $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 # 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. # the user know if the version is too old to be used with Bugzilla.
if ( vers_cmp($sql_vers,$sql_want) > -1 ) { if (!$version_ok) {
print "ok: found v$sql_vers\n" if $output;
} else {
die <<EOT; die <<EOT;
Your $sql_server v$sql_vers is too old. Bugzilla requires version Your $sql_server v$sql_vers is too old. Bugzilla requires version
......
...@@ -29,7 +29,9 @@ use strict; ...@@ -29,7 +29,9 @@ use strict;
use Bugzilla::Constants; use Bugzilla::Constants;
use Encode; use Encode;
use ExtUtils::MM ();
use File::Basename; use File::Basename;
use File::Spec;
use POSIX qw(setlocale LC_CTYPE); use POSIX qw(setlocale LC_CTYPE);
use Safe; use Safe;
use Scalar::Util qw(tainted); use Scalar::Util qw(tainted);
...@@ -54,18 +56,19 @@ our @EXPORT_OK = qw( ...@@ -54,18 +56,19 @@ our @EXPORT_OK = qw(
); );
sub bin_loc { sub bin_loc {
my ($bin) = @_; my ($bin, $path) = @_;
return '' if ON_WINDOWS; my @path = $path ? @$path : File::Spec->path;
# Don't print any errors from "which"
open(my $saveerr, ">&STDERR"); foreach my $dir (@path) {
open(STDERR, '>/dev/null'); next if !-d $dir;
my $loc = `which $bin`; my $full_path = File::Spec->catfile($dir, $bin);
close(STDERR); # MM is an alias for ExtUtils::MM. maybe_command is nice
open(STDERR, ">&", $saveerr); # because it checks .com, .bat, .exe (etc.) on Windows.
my $exit_code = $? >> 8; # See the perlvar manpage. my $command = MM->maybe_command($full_path);
return '' if $exit_code > 0; return $command if $command;
chomp($loc); }
return $loc;
return '';
} }
sub get_version_and_os { sub get_version_and_os {
......
...@@ -399,10 +399,17 @@ sub multiline_sprintf { ...@@ -399,10 +399,17 @@ sub multiline_sprintf {
sub _mtime { return (stat($_[0]))[9] } sub _mtime { return (stat($_[0]))[9] }
sub mtime_filter { sub mtime_filter {
my ($file_url) = @_; my ($file_url, $mtime) = @_;
my $cgi_path = bz_locations()->{'cgi_path'}; # This environment var is set in the .htaccess if we have mod_headers
my $file_path = "$cgi_path/$file_url"; # and mod_expires installed, to make sure that JS and CSS with "?"
return "$file_url?" . _mtime($file_path); # 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: # Set up the skin CSS cascade:
...@@ -453,8 +460,7 @@ sub css_files { ...@@ -453,8 +460,7 @@ sub css_files {
sub _css_link_set { sub _css_link_set {
my ($file_name) = @_; my ($file_name) = @_;
my $standard_mtime = _mtime($file_name); my %set = (standard => mtime_filter($file_name));
my %set = (standard => $file_name . "?$standard_mtime");
# We use (^|/) to allow Extensions to use the skins system if they # We use (^|/) to allow Extensions to use the skins system if they
# want. # want.
...@@ -471,7 +477,7 @@ sub _css_link_set { ...@@ -471,7 +477,7 @@ sub _css_link_set {
my $skin_file_name = $file_name; my $skin_file_name = $file_name;
$skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$option/}; $skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$option/};
if (my $mtime = _mtime("$cgi_path/$skin_file_name")) { 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; $set{alternate} = \%skin_urls;
...@@ -484,7 +490,7 @@ sub _css_link_set { ...@@ -484,7 +490,7 @@ sub _css_link_set {
my $custom_file_name = $file_name; my $custom_file_name = $file_name;
$custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/}; $custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/};
if (my $custom_mtime = _mtime("$cgi_path/$custom_file_name")) { 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; return \%set;
......
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
%strings = ( %strings = (
any => 'any', 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##', bad_executable => 'not a valid executable: ##bin##',
blacklisted => '(blacklisted)', blacklisted => '(blacklisted)',
bz_schema_exists_before_220 => <<'END', bz_schema_exists_before_220 => <<'END',
...@@ -260,6 +265,18 @@ EOT ...@@ -260,6 +265,18 @@ EOT
# Note: When translating these "modules" messages, don't change the formatting # Note: When translating these "modules" messages, don't change the formatting
# if possible, because there is hardcoded formatting in # if possible, because there is hardcoded formatting in
# Bugzilla::Install::Requirements to match the box formatting. # 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, modules_message_db => <<EOT,
*********************************************************************** ***********************************************************************
* DATABASE ACCESS * * 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