]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 950486: Move the webdotbase and font_file parameters from data/params into localc...
authorMatt Selsky <selsky@columbia.edu>
Mon, 15 Dec 2014 17:47:48 +0000 (17:47 +0000)
committerGervase Markham <gerv@gerv.net>
Mon, 15 Dec 2014 17:47:48 +0000 (17:47 +0000)
14 files changed:
Bugzilla/Config/Common.pm
Bugzilla/Install/Filesystem.pm
Bugzilla/Install/Localconfig.pm
Bugzilla/Install/Requirements.pm
checksetup.pl
docs/en/rst/administering/parameters.rst
editparams.cgi
showdependencygraph.cgi
template/en/default/bug/edit.html.tmpl
template/en/default/reports/chart.png.tmpl
template/en/default/reports/report-bar.png.tmpl
template/en/default/reports/report-line.png.tmpl
template/en/default/reports/report-pie.png.tmpl
template/en/default/setup/strings.txt.pl

index fe6a2c2c0aa8cfc8b5cedd2762f5f64b64166eca..f7e37c6fc5f1d3cb116a0237af7553bfe548a39b 100644 (file)
@@ -24,9 +24,8 @@ use parent qw(Exporter);
 @Bugzilla::Config::Common::EXPORT =
     qw(check_multi check_numeric check_regexp check_url check_group
        check_sslbase check_priority check_severity check_platform
-       check_opsys check_shadowdb check_urlbase check_webdotbase
-       check_user_verify_class check_ip check_font_file
-       check_mail_delivery_method check_notification check_utf8
+       check_opsys check_shadowdb check_urlbase check_user_verify_class
+       check_ip check_mail_delivery_method check_notification check_utf8
        check_bug_status check_smtp_auth check_theschwartz_available
        check_maxattachmentsize check_email check_smtp_ssl
        check_comment_taggers_group check_smtp_server
@@ -85,7 +84,7 @@ sub check_sslbase {
     my $url = shift;
     if ($url ne '') {
         if ($url !~ m#^https://([^/]+).*/$#) {
-            return "must be a legal URL, that starts with https and ends with a slash.";
+            return "must be a legal URL, that starts with https and ends with a slash";
         }
         my $host = $1;
         # Fall back to port 443 if for some reason getservbyname() fails.
@@ -221,43 +220,6 @@ sub check_url {
     return '';
 }
 
-sub check_webdotbase {
-    my ($value) = (@_);
-    $value = trim($value);
-    if ($value eq "") {
-        return "";
-    }
-    if($value !~ /^https?:/) {
-        if(! -x $value) {
-            return "The file path \"$value\" is not a valid executable.  Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
-        }
-        # Check .htaccess allows access to generated images
-        my $webdotdir = bz_locations()->{'webdotdir'};
-        if(-e "$webdotdir/.htaccess") {
-            open HTACCESS, "$webdotdir/.htaccess";
-            if(! grep(/ \\\.png\$/,<HTACCESS>)) {
-                return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
-            }
-            close HTACCESS;
-        }
-    }
-    return "";
-}
-
-sub check_font_file {
-    my ($font) = @_;
-    $font = trim($font);
-    return '' unless $font;
-
-    if ($font !~ /\.ttf$/) {
-        return "The file must point to a TrueType font file (its extension must be .ttf)"
-    }
-    if (! -f $font) {
-        return "The file '$font' cannot be found. Make sure you typed the full path to the file"
-    }
-    return '';
-}
-
 sub check_user_verify_class {
     # doeditparams traverses the list of params, and for each one it checks,
     # then updates. This means that if one param checker wants to look at 
@@ -535,10 +497,6 @@ valid group is provided.
 
 =item check_email
 
-=item check_webdotbase
-
-=item check_font_file
-
 =item get_param_list
 
 =item check_maxattachmentsize
index 523c09fecfc6ca7fc831e26ad2438d0c8a12caa4..2120cbc573a1392a6194083d9abfada3ad920b4a 100644 (file)
@@ -349,13 +349,13 @@ EOT
         },
 
         "$webdotdir/.htaccess" => { perms => WS_SERVE, contents => <<EOT
-# Restrict access to .dot files to the public webdot server at research.att.com
-# if research.att.com ever changes their IP, or if you use a different
-# webdot server, you'll need to edit this
-<FilesMatch \\.dot\$>
-  Allow from 192.20.225.0/24
-  Deny from all
-</FilesMatch>
+# If you run a local webdot server, you will need to allow it access to
+# generated .dot files. Uncomment this section and replace the IP address with
+# the IP address of your webdot server.
+#<FilesMatch \\.dot\$>
+#  Allow from 127.0.0.1/24
+#  Deny from all
+#</FilesMatch>
 
 # Allow access to .png files created by a local copy of 'dot'
 <FilesMatch \\.png\$>
index 7f473cc77f2b5035f0f0d1622b47f45c34468761..4ccd107ae3eb1b024d9caf8d1db3dd641fcded35 100644 (file)
@@ -108,6 +108,14 @@ use constant LOCALCONFIG_VARS => (
         name    => 'diffpath',
         default => sub { dirname(bin_loc('diff')) },
     },
+    {
+        name    => 'font_file',
+        default => '',
+    },
+    {
+        name    => 'webdotbase',
+        default => '',
+    },
     {
         name    => 'site_wide_secret',
         # 64 characters is roughly the equivalent of a 384-bit key, which
@@ -225,6 +233,9 @@ sub update_localconfig {
             if (exists $answer->{$name}) {
                 $localconfig->{$name} = $answer->{$name};
             }
+            elsif (exists Bugzilla->params->{$name}) {
+                $localconfig->{$name} = Bugzilla->params->{$name};
+            }
             else {
                 # If the user did not supply an answers file, then they get
                 # notified about every variable that gets added. If there was
index 622d1db666ed856fd8fed15892b324225af0226b..ee50a526ab0f0cf190a2026a23055d8a328b589e 100644 (file)
@@ -30,7 +30,8 @@ our @EXPORT = qw(
     FEATURE_FILES
 
     check_requirements
-    check_graphviz
+    check_webdotbase
+    check_font_file
     have_vers
     install_command
     map_files_to_features
@@ -655,10 +656,10 @@ sub _translate_feature {
     return join(', ', @strings);
 }
 
-sub check_graphviz {
+sub check_webdotbase {
     my ($output) = @_;
 
-    my $webdotbase = Bugzilla->params->{'webdotbase'};
+    my $webdotbase = Bugzilla->localconfig->{'webdotbase'};
     return 1 if $webdotbase =~ /^https?:/;
 
     my $return;
@@ -677,7 +678,7 @@ sub check_graphviz {
     if (-e "$webdotdir/.htaccess") {
         my $htaccess = new IO::File("$webdotdir/.htaccess", 'r') 
             || die "$webdotdir/.htaccess: " . $!;
-        if (!grep(/png/, $htaccess->getlines)) {
+        if (!grep(/ \\\.png\$/, $htaccess->getlines)) {
             print STDERR install_string('webdot_bad_htaccess',
                                         { dir => $webdotdir }), "\n";
         }
@@ -687,6 +688,31 @@ sub check_graphviz {
     return $return;
 }
 
+sub check_font_file {
+    my ($output) = @_;
+
+    my $font_file = Bugzilla->localconfig->{'font_file'};
+
+    my $readable;
+    $readable = 1 if -r $font_file;
+
+    my $ttf;
+    $ttf = 1 if $font_file =~ /\.ttf$/;
+
+    if ($output) {
+        _checking_for({ package => 'Font file', ok => $readable && $ttf});
+    }
+
+    if (!$readable) {
+        print install_string('bad_font_file', { file => $font_file }), "\n";
+    }
+    elsif (!$ttf) {
+        print install_string('bad_font_file_name', { file => $font_file }), "\n";
+    }
+
+    return $readable && $ttf;
+}
+
 # This was originally clipped from the libnet Makefile.PL, adapted here for
 # accurate version checking.
 sub have_vers {
@@ -910,7 +936,7 @@ optional modules.
 
 =back
 
-=item C<check_graphviz($output)>
+=item C<check_webdotbase($output)>
 
 Description: Checks if the graphviz binary specified in the 
   C<webdotbase> parameter is a valid binary, or a valid URL.
@@ -920,6 +946,16 @@ Params:      C<$output> - C<$true> if you want the function to
 
 Returns:     C<1> if the check was successful, C<0> otherwise.
 
+=item C<check_font_file($output)>
+
+Description: Checks if the font file specified in the C<font_type> parameter
+  is a valid-looking font file.
+
+Params:      C<$output> - C<$true> if you want the function to
+                 print out information about what it's doing.
+
+Returns:     C<1> if the check was successful, C<0> otherwise.
+
 =item C<have_vers($module, $output)>
 
  Description: Tells you whether or not you have the appropriate
index 50ca8bda878eb50a90a8c28221ddd5896c5f4008..eb6b3f85781df313c0dfc921af1eaaf7db3ec2d0 100755 (executable)
@@ -151,7 +151,15 @@ fix_all_file_permissions(!$silent);
 
 # If we are using a local 'dot' binary, verify the specified binary exists
 # and that the generated images are accessible.
-check_graphviz(!$silent) if Bugzilla->params->{'webdotbase'};
+check_webdotbase(!$silent) if $lc_hash->{'webdotbase'};
+
+###########################################################################
+# Check font file setup
+###########################################################################
+
+# If we are using a local font file, verify the specified file exists and
+# that it has the correct extension.
+check_font_file(!$silent) if $lc_hash->{'font_file'};
 
 ###########################################################################
 # Changes to the fielddefs --TABLE--
index 1a09990938bc738781bb6f098967c07bfb5bfc1e..ce6a55f6a1a42e5ed8bb551a4109a5c9b5d42314 100644 (file)
@@ -337,42 +337,6 @@ collapsed_comment_tags
     A comma-separated list of tags which, when applied to comments, will
     cause them to be collapsed by default.
 
-.. _param-dependency-graphs:
-
-Graphs
-======
-
-Bugzilla can draw graphs of bug-dependency relationships, using a tool called
-:file:`dot` (from the `GraphViz project <http://graphviz.org/>`_) or a web
-service called Web Dot. This page allows you to set the location of the binary
-or service. If no Web Dot server or binary is specified, then dependency
-graphs will be disabled.
-
-webdotbase
-    You may set this parameter to any of the following:
-
-    * A complete file path to :command:`dot` (part of GraphViz), which will
-      generate the graphs locally.
-    * A URL prefix pointing to an installation of the Web Dot package, which
-      will generate the graphs remotely.
-    * A blank value, which will disable dependency graphing.
-
-    The default value is blank. We recommend using a local install of
-    :file:`dot`. If you change this value to a web service, make certain that
-    the Web Dot server can read files from your Web Dot directory. On Apache
-    you do this by editing the :file:`.htaccess` file; for other systems the
-    needed measures may vary. You can run :command:`checksetup.pl` to
-    recreate the :file:`.htaccess` file if it has been lost.
-
-font_file
-    You can specify the full path to a TrueType font file which will be used
-    to display text (labels, legends, ...) in charts and graphical reports.
-    To support as many languages as possible, we recommend to specify a
-    TrueType font such as Unifont which supports all printable characters in
-    the Basic Multilingual Plane. If you leave this parameter empty, a default
-    font will be used, but its support is limited to English characters only
-    and so other characters will be displayed incorrectly. 
-
 .. _param-group-security:
 
 Group Security
index ae569c2eb4bdba8eb8758724aac4454556363ec5..5484f5fdc17770da9279e26c37fbbdf864adbccc 100755 (executable)
@@ -89,7 +89,7 @@ if ($action eq 'save' && $current_module) {
             }
             # Stop complaining if the URL has no trailing slash.
             # XXX - This hack can go away once bug 303662 is implemented.
-            if ($name =~ /(?<!webdot)base$/) {
+            if ($name =~ /base$/) {
                 $value = "$value/" if ($value && $value !~ m#/$#);
             }
         }
index 02c8fd94f7a7ae9deb72bff120443aa8da3c0ad9..528b9cd61909c76d8cb7324548f8796e41e86bd3 100755 (executable)
@@ -235,7 +235,7 @@ if ($bug_count > MAX_WEBDOT_BUGS) {
     ThrowUserError("webdot_too_large");
 }
 
-my $webdotbase = Bugzilla->params->{'webdotbase'};
+my $webdotbase = Bugzilla->localconfig->{'webdotbase'};
 
 if ($webdotbase =~ /^https?:/) {
      # Remote dot server. We don't hardcode 'urlbase' here in case
index 516a24ed8ec460b82d5a2fa0f94bbff4252883c6..e27f47263b55ebca1b225a1e53ea072617362545 100644 (file)
       <td colspan="2" id="show_dependency_tree_or_graph">
         Show dependency <a href="showdependencytree.cgi?id=[% bug.bug_id %]&amp;hide_resolved=1">tree</a>
 
-        [% IF Param('webdotbase') %]
+        [% USE Bugzilla %]
+        [% IF Bugzilla.localconfig.webdotbase %]
           /&nbsp;<a href="showdependencygraph.cgi?id=[% bug.bug_id %]">graph</a>
         [% END %]
       </td>
 
 [% BLOCK section_customfields %]
 [%# *** Custom Fields *** %]
-  [% USE Bugzilla %]
   [% FOREACH field = Bugzilla.active_custom_fields %]
     <tr>
       [% PROCESS bug/field.html.tmpl value = bug.${field.name}
index 91944fee5286a24b2a397874a23ac8ca47fce565..336efda2ac6c92f3a0217280faa6e540325ed80e 100644 (file)
   END;
 -%]
 
-[% IF Param("font_file") %]
-  [% graph.set_x_axis_font(Param("font_file"), 9);
-     graph.set_x_label_font(Param("font_file"), 10);
-     graph.set_y_axis_font(Param("font_file"), 9);
-     graph.set_y_label_font(Param("font_file"), 10);
-     graph.set_legend_font(Param("font_file"), 9);
+[% USE Bugzilla %]
+[% IF Bugzilla.localconfig.font_file %]
+  [% graph.set_x_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_x_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_y_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_y_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_legend_font(Bugzilla.localconfig.font_file, 9);
   %]
 [% END %]
 
index d879f6dd1752c14b43763b58f5a7f9a070e939cc..3f0faa5d9275835b74ce54ecff966e5e79196743 100644 (file)
   END;
 -%]
 
-[% IF Param("font_file") %]
-  [% graph.set_x_axis_font(Param("font_file"), 9);
-     graph.set_x_label_font(Param("font_file"), 10);
-     graph.set_y_axis_font(Param("font_file"), 9);
-     graph.set_y_label_font(Param("font_file"), 10);
-     graph.set_legend_font(Param("font_file"), 9);
+[% USE Bugzilla %]
+[% IF Bugzilla.localconfig.font_file %]
+  [% graph.set_x_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_x_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_y_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_y_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_legend_font(Bugzilla.localconfig.font_file, 9);
   %]
 [% END %]
 
index 585133afd4d09162258c832e305cec14938a6dee..a4baff641ce2511f6ebf9b42357d5dac430f6449 100644 (file)
   END;
 -%]
 
-[% IF Param("font_file") %]
-  [% graph.set_x_axis_font(Param("font_file"), 9);
-     graph.set_x_label_font(Param("font_file"), 10);
-     graph.set_y_axis_font(Param("font_file"), 9);
-     graph.set_y_label_font(Param("font_file"), 10);
-     graph.set_legend_font(Param("font_file"), 9);
+[% USE Bugzilla %]
+[% IF Bugzilla.localconfig.font_file %]
+  [% graph.set_x_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_x_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_y_axis_font(Bugzilla.localconfig.font_file, 9);
+     graph.set_y_label_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_legend_font(Bugzilla.localconfig.font_file, 9);
   %]
 [% END %]
 
index cc2a1325ae74a52fd4c78216b66ac1263fd247c4..6808cfb772f1b0918ba003d9614de4bb6f5d16c1 100644 (file)
   END;
 -%]
 
-[% IF Param("font_file") %]
-  [% graph.set_title_font(Param("font_file"), 10);
-     graph.set_value_font(Param("font_file"), 9);
+[% USE Bugzilla %]
+[% IF Bugzilla.localconfig.font_file %]
+  [% graph.set_title_font(Bugzilla.localconfig.font_file, 10);
+     graph.set_value_font(Bugzilla.localconfig.font_file, 9);
   %]
 [% END %]
 
index c63d65ce1a062dd9c36f74462b9b91a7b8f81b25..b6cd693d7a442ab39c9475775749a929a6643f81 100644 (file)
@@ -23,6 +23,13 @@ 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_font_file => <<'END',
+The file ##file## cannot be found. Make sure you typed the full path to the file
+END
+    bad_font_file_name => <<'END',
+The file ##file## must point to a TrueType font file (its extension must be
+.ttf)
+END
     blacklisted => '(blacklisted)',
     bz_schema_exists_before_220 => <<'END',
 You are upgrading from a version before 2.20, but the bz_schema table
@@ -214,6 +221,15 @@ END
 For the "Difference Between Two Patches" feature to work, we need to know
 what directory the "diff" bin is in. (You only need to set this if you
 are using that feature of the Patch Viewer.)
+END
+    localconfig_font_file => <<'END',
+You can specify the full path to a TrueType font file, which will be used to
+display text (labels, legends, ...) in charts and graphical reports. To support
+as many languages as possible, we recommend to specify a TrueType font such as
+Unifont (http://unifoundry.com/unifont.html), which supports all printable
+characters in the Basic Multilingual Plane. If you leave this parameter empty,
+a default font will be used, but its support is limited to English characters
+only and so other characters will be displayed incorrectly.
 END
     localconfig_index_html => <<'END',
 Most web servers will allow you to use index.cgi as a directory
@@ -251,6 +267,21 @@ a normal webserver environment.
 
 If set to 1, checksetup.pl will set file permissions so that Bugzilla
 works in a SuexecUserGroup environment. 
+END
+    localconfig_webdotbase => <<'END',
+It is possible to show graphs of dependent bugs. You may set this parameter to
+any of the following:
+
+- A complete file path to 'dot' (part of GraphViz (http://www.graphviz.org/))
+  will generate the graphs locally.
+- A URL prefix pointing to an installation of the webdot package will generate
+  the graphs remotely. (append "/%urlbase%" to the URL prefix)
+- A blank value will disable dependency graphing.
+
+If you use a webdot URL prefix, make certain that the webdot server can read
+files from your webdot directory. On Apache you do this by editing the
+.htaccess file, for other systems the needed measures may vary. You can run
+checksetup.pl to recreate the .htaccess file if it has been lost.
 END
     localconfig_webservergroup => <<'END',
 The name of the group that your web server runs as. On Red Hat