Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
6103e15f
Commit
6103e15f
authored
Nov 28, 2011
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 705393: Improve the error message thrown by Update.pm when updates.bugzilla.org is unavailable
r=glob a=LpSolit
parent
1710b67c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
Constants.pm
Bugzilla/Constants.pm
+7
-0
Update.pm
Bugzilla/Update.pm
+13
-13
index.html.tmpl
template/en/default/index.html.tmpl
+11
-5
No files found.
Bugzilla/Constants.pm
View file @
6103e15f
...
@@ -40,6 +40,9 @@ use Memoize;
...
@@ -40,6 +40,9 @@ use Memoize;
@
Bugzilla::Constants::
EXPORT
=
qw(
@
Bugzilla::Constants::
EXPORT
=
qw(
BUGZILLA_VERSION
BUGZILLA_VERSION
REMOTE_FILE
LOCAL_FILE
bz_locations
bz_locations
IS_NULL
IS_NULL
...
@@ -201,6 +204,10 @@ use Memoize;
...
@@ -201,6 +204,10 @@ use Memoize;
# Bugzilla version
# Bugzilla version
use
constant
BUGZILLA_VERSION
=>
"4.3"
;
use
constant
BUGZILLA_VERSION
=>
"4.3"
;
# Location of the remote and local XML files to track new releases.
use
constant
REMOTE_FILE
=>
'http://updates.bugzilla.org/bugzilla-update.xml'
;
use
constant
LOCAL_FILE
=>
'bugzilla-update.xml'
;
# Relative to datadir.
# These are unique values that are unlikely to match a string or a number,
# These are unique values that are unlikely to match a string or a number,
# to be used in criteria for match() functions and other things. They start
# to be used in criteria for match() functions and other things. They start
# and end with spaces because most Bugzilla stuff has trim() called on it,
# and end with spaces because most Bugzilla stuff has trim() called on it,
...
...
Bugzilla/Update.pm
View file @
6103e15f
...
@@ -20,8 +20,6 @@ use strict;
...
@@ -20,8 +20,6 @@ use strict;
use
Bugzilla::
Constants
;
use
Bugzilla::
Constants
;
use
constant
REMOTE_FILE
=>
'http://updates.bugzilla.org/bugzilla-update.xml'
;
use
constant
LOCAL_FILE
=>
"/bugzilla-update.xml"
;
# Relative to datadir.
use
constant
TIME_INTERVAL
=>
86400
;
# Default is one day, in seconds.
use
constant
TIME_INTERVAL
=>
86400
;
# Default is one day, in seconds.
use
constant
TIMEOUT
=>
5
;
# Number of seconds before timeout.
use
constant
TIMEOUT
=>
5
;
# Number of seconds before timeout.
...
@@ -30,26 +28,25 @@ sub get_notifications {
...
@@ -30,26 +28,25 @@ sub get_notifications {
return
if
!
Bugzilla
->
feature
(
'updates'
);
return
if
!
Bugzilla
->
feature
(
'updates'
);
return
if
(
Bugzilla
->
params
->
{
'upgrade_notification'
}
eq
'disabled'
);
return
if
(
Bugzilla
->
params
->
{
'upgrade_notification'
}
eq
'disabled'
);
my
$local_file
=
bz_locations
()
->
{
'datadir'
}
.
LOCAL_FILE
;
my
$local_file
=
bz_locations
()
->
{
'datadir'
}
.
'/'
.
LOCAL_FILE
;
# Update the local XML file if this one doesn't exist or if
# Update the local XML file if this one doesn't exist or if
# the last modification time (stat[9]) is older than TIME_INTERVAL.
# the last modification time (stat[9]) is older than TIME_INTERVAL.
if
(
!-
e
$local_file
||
(
time
()
-
(
stat
(
$local_file
))[
9
]
>
TIME_INTERVAL
))
{
if
(
!-
e
$local_file
||
(
time
()
-
(
stat
(
$local_file
))[
9
]
>
TIME_INTERVAL
))
{
unlink
$local_file
;
# Make sure the old copy is away.
unlink
$local_file
;
# Make sure the old copy is away.
if
(
-
e
$local_file
)
{
return
{
'error'
=>
'no_update'
}
if
(
-
e
$local_file
);
return
{
'error'
=>
'no_update'
,
xml_file
=>
$local_file
};
}
my
$error
=
_synchronize_data
();
my
$error
=
_synchronize_data
();
# If an error is returned, leave now.
# If an error is returned, leave now.
return
$error
if
$error
;
return
$error
if
$error
;
}
}
# If we cannot access the local XML file, ignore it.
# If we cannot access the local XML file, ignore it.
return
{
'error'
=>
'no_access'
,
'xml_file'
=>
$local_file
}
unless
(
-
r
$local_file
);
return
{
'error'
=>
'no_access'
}
unless
(
-
r
$local_file
);
my
$twig
=
XML::
Twig
->
new
();
my
$twig
=
XML::
Twig
->
new
();
$twig
->
safe_parsefile
(
$local_file
);
$twig
->
safe_parsefile
(
$local_file
);
# If the XML file is invalid, return.
# If the XML file is invalid, return.
return
{
'error'
=>
'corrupted'
,
'xml_file'
=>
$local_file
}
if
$@
;
return
{
'error'
=>
'corrupted'
}
if
$@
;
my
$root
=
$twig
->
root
;
my
$root
=
$twig
->
root
;
my
@releases
;
my
@releases
;
...
@@ -119,7 +116,7 @@ sub get_notifications {
...
@@ -119,7 +116,7 @@ sub get_notifications {
}
}
sub
_synchronize_data
{
sub
_synchronize_data
{
my
$local_file
=
bz_locations
()
->
{
'datadir'
}
.
LOCAL_FILE
;
my
$local_file
=
bz_locations
()
->
{
'datadir'
}
.
'/'
.
LOCAL_FILE
;
my
$ua
=
LWP::
UserAgent
->
new
();
my
$ua
=
LWP::
UserAgent
->
new
();
$ua
->
timeout
(
TIMEOUT
);
$ua
->
timeout
(
TIMEOUT
);
...
@@ -133,7 +130,7 @@ sub _synchronize_data {
...
@@ -133,7 +130,7 @@ sub _synchronize_data {
else
{
else
{
$ua
->
env_proxy
;
$ua
->
env_proxy
;
}
}
$ua
->
mirror
(
REMOTE_FILE
,
$local_file
)
;
my
$response
=
eval
{
$ua
->
mirror
(
REMOTE_FILE
,
$local_file
)
}
;
# $ua->mirror() forces the modification time of the local XML file
# $ua->mirror() forces the modification time of the local XML file
# to match the modification time of the remote one.
# to match the modification time of the remote one.
...
@@ -144,11 +141,14 @@ sub _synchronize_data {
...
@@ -144,11 +141,14 @@ sub _synchronize_data {
# Try to alter its last modification time.
# Try to alter its last modification time.
my
$can_alter
=
utime
(
undef
,
undef
,
$local_file
);
my
$can_alter
=
utime
(
undef
,
undef
,
$local_file
);
# This error should never happen.
# This error should never happen.
$can_alter
||
return
{
'error'
=>
'no_update'
,
'xml_file'
=>
$local_file
};
$can_alter
||
return
{
'error'
=>
'no_update'
};
}
}
els
e
{
els
if
(
$response
&&
$response
->
is_error
)
{
# We have been unable to download the file.
# We have been unable to download the file.
return
{
'error'
=>
'cannot_download'
,
'xml_file'
=>
$local_file
};
return
{
'error'
=>
'cannot_download'
,
'reason'
=>
$response
->
status_line
};
}
else
{
return
{
'error'
=>
'no_write'
,
'reason'
=>
$@
};
}
}
# Everything went well.
# Everything went well.
...
...
template/en/default/index.html.tmpl
View file @
6103e15f
...
@@ -89,18 +89,24 @@ YAHOO.util.Event.onDOMReady(onLoadActions);
...
@@ -89,18 +89,24 @@ YAHOO.util.Event.onDOMReady(onLoadActions);
You can configure this notification from the
You can configure this notification from the
<a
href=
"editparams.cgi?section=general#upgrade_notification_desc"
>
Parameters
</a>
page.
</p>
<a
href=
"editparams.cgi?section=general#upgrade_notification_desc"
>
Parameters
</a>
page.
</p>
[% ELSIF release.error == "cannot_download" %]
[% ELSIF release.error == "cannot_download" %]
<p>
The local XML file '[% release.xml_file FILTER html %]' cannot be created.
<p>
The remote file
<a
href=
"[% constants.REMOTE_FILE FILTER html %]"
>
Please make sure the web server can write in this directory and that you can access
[%~ constants.REMOTE_FILE FILTER html %]
</a>
cannot be downloaded
(reason: [% release.reason FILTER html %]).
<br>
Either the remote server is temporarily unavailable, or your web server cannot access
the web. If you are behind a proxy, set the
the web. If you are behind a proxy, set the
<a
href=
"editparams.cgi?section=advanced#proxy_url_desc"
>
proxy_url
</a>
parameter correctly.
</p>
<a
href=
"editparams.cgi?section=advanced#proxy_url_desc"
>
proxy_url
</a>
parameter correctly.
</p>
[% ELSIF release.error == "no_write" %]
<p>
The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be created
(reason: [% release.reason FILTER html %]).
<br>
Please make sure the web server can write into this directory.
[% ELSIF release.error == "no_update" %]
[% ELSIF release.error == "no_update" %]
<p>
The local XML file '[%
release.xml_file
FILTER html %]' cannot be updated.
<p>
The local XML file '[%
constants.LOCAL_FILE
FILTER html %]' cannot be updated.
Please make sure the web server can edit this file.
</p>
Please make sure the web server can edit this file.
</p>
[% ELSIF release.error == "no_access" %]
[% ELSIF release.error == "no_access" %]
<p>
The local XML file '[%
release.xml_file
FILTER html %]' cannot be read.
<p>
The local XML file '[%
constants.LOCAL_FILE
FILTER html %]' cannot be read.
Please make sure this file 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" %]
[% ELSIF release.error == "corrupted" %]
<p>
The local XML file '[%
release.xml_file
FILTER html %]' has an invalid XML format.
<p>
The local XML file '[%
constants.LOCAL_FILE
FILTER html %]' has an invalid XML format.
Please delete it and try accessing this page again.
</p>
Please delete it and try accessing this page again.
</p>
[% ELSIF release.error == "unknown_parameter" %]
[% ELSIF release.error == "unknown_parameter" %]
<p>
'[% Param("upgrade_notification") FILTER html %]' is not a valid notification
<p>
'[% Param("upgrade_notification") FILTER html %]' is not a valid notification
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment