]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 350112: Error about "data/bugzilla-update.xml" being unreadable - Patch by FrÃ...
authorlpsolit%gmail.com <>
Wed, 18 Apr 2007 05:15:13 +0000 (05:15 +0000)
committerlpsolit%gmail.com <>
Wed, 18 Apr 2007 05:15:13 +0000 (05:15 +0000)
Bugzilla/Config/Core.pm
Bugzilla/Update.pm
template/en/default/admin/params/core.html.tmpl
template/en/default/index.html.tmpl

index 33eb46ac515a6d3127a86b7c049d7be9edf9f9c8..a0aca9c9b095c6df34fb785370eda57949816313 100644 (file)
@@ -113,6 +113,12 @@ sub get_param_list {
    default => ''
   },
 
+  {
+   name => 'proxy_url',
+   type => 't',
+   default => ''
+  },
+
   {
    name => 'upgrade_notification',
    type => 's',
index e5d4f86f90eb2416c95fd4e435ea11c447559ff2..596290ab9f7a5a4873de083351150408c140a25d 100644 (file)
@@ -46,7 +46,9 @@ sub get_notifications {
             $can_alter = utime(undef, undef, $local_file);
         }
         if ($can_alter) {
-            _synchronize_data();
+            my $error = _synchronize_data();
+            # If an error is returned, leave now.
+            return $error if $error;
         }
         else {
             return {'error' => 'no_update', 'xml_file' => $local_file};
@@ -130,14 +132,22 @@ sub get_notifications {
 
 sub _synchronize_data {
     eval("require LWP::UserAgent");
-    return if $@;
+    return {'error' => 'missing_package', 'package' => 'LWP::UserAgent'} if $@;
 
     my $local_file = bz_locations()->{'datadir'} . LOCAL_FILE;
 
     my $ua = LWP::UserAgent->new();
     $ua->timeout(TIMEOUT);
     $ua->protocols_allowed(['http', 'https']);
-    $ua->env_proxy;
+    # If the URL of the proxy is given, use it, else get this information
+    # from the environment variable.
+    my $proxy_url = Bugzilla->params->{'proxy_url'};
+    if ($proxy_url) {
+        $ua->proxy(['http', 'https'], $proxy_url);
+    }
+    else {
+        $ua->env_proxy;
+    }
     $ua->mirror(REMOTE_FILE, $local_file);
 
     # $ua->mirror() forces the modification time of the local XML file
@@ -145,7 +155,19 @@ sub _synchronize_data {
     # So we have to update it manually to reflect that a newer version
     # of the file has effectively been requested. This will avoid
     # any new download for the next TIME_INTERVAL.
-    utime(undef, undef, $local_file);
+    if (-e $local_file) {
+        # Try to alter its last modification time.
+        my $can_alter = utime(undef, undef, $local_file);
+        # This error should never happen.
+        $can_alter || return {'error' => 'no_update', 'xml_file' => $local_file};
+    }
+    else {
+        # We have been unable to download the file.
+        return {'error' => 'cannot_download', 'xml_file' => $local_file};
+    }
+
+    # Everything went well.
+    return 0;
 }
 
 sub _compare_versions {
index 2ab6856a884d633aaa295cb4257943b9e6babbb9..9ad312cfb1db5e506bb12a1b8e0900480b2a065b 100644 (file)
                   "centered text, use <em>style=\"text-align: " _
                   "center;\"</em>.",
 
+  proxy_url => "$terms.Bugzilla may have to access the web to get notifications about new " _
+               "releases, see the <tt>upgrade_notification</tt> parameter. In case you are " _
+               "behind a proxy, it may be necessary to enter its URL if the web server " _
+               "group cannot access the HTTP_PROXY environment variable.",
+
   upgrade_notification => "<p>$terms.Bugzilla can inform you when a new release is available. " _
                           "The notification will appear on the $terms.Bugzilla homepage, " _
                           "for administrators only.</p>" _
index a96f2b15eb9fc7028c2d32578f0925805860d487..d7c74e18801bb0360f24f41a4bc7f80b4eb1d13f 100644 (file)
@@ -75,12 +75,18 @@ function addSidebar() {
       <p class="notice">This message is only shown to logged in users with admin privs.
       You can configure this notification from the
       <a href="editparams.cgi?section=core#upgrade_notification">Parameters</a> page.</p>
+    [% ELSIF release.error == "missing_package" %]
+      <p>Missing package '[% release.package FILTER html %]'. This package is required to
+      <a href="editparams.cgi?section=core#upgrade_notification">notify you about new releases</a>.</p>
+    [% ELSIF release.error == "cannot_download" %]
+      <p>The local XML file '[% release.xml_file FILTER html %]' cannot be created.
+      Please make sure the web server can write in this directory.</p>
     [% ELSIF release.error == "no_update" %]
       <p>The local XML file '[% release.xml_file FILTER html %]' cannot be updated.
       Please make sure the web server can edit this file.</p>
     [% ELSIF release.error == "no_access" %]
       <p>The local XML file '[% release.xml_file FILTER html %]' cannot be read.
-      Please make sure this file exists and has the correct rights set on it.</p>
+      Please make sure this file has the correct rights set on it.</p>
     [% ELSIF release.error == "corrupted" %]
       <p>The local XML file '[% release.xml_file FILTER html %]' has an invalid XML format.
       Please delete it and try accessing this page again.</p>