Commit 59b918bb authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 265188: GenerateVersionTable should only overwrite versioncache if it's…

Bug 265188: GenerateVersionTable should only overwrite versioncache if it's changed - Patch by Frédéric Buclin <LpSolit@gmail.com> r=glob,justdave a=justdave
parent 20e0d1f7
...@@ -308,6 +308,8 @@ if ($action eq 'update') { ...@@ -308,6 +308,8 @@ if ($action eq 'update') {
SET name=? WHERE id=?"); SET name=? WHERE id=?");
$sth->execute($classification,$classification_id); $sth->execute($classification,$classification_id);
$vars->{'updated_classification'} = 1; $vars->{'updated_classification'} = 1;
unlink "$datadir/versioncache";
} }
if ($description ne $descriptionold) { if ($description ne $descriptionold) {
...@@ -316,11 +318,12 @@ if ($action eq 'update') { ...@@ -316,11 +318,12 @@ if ($action eq 'update') {
WHERE id=?"); WHERE id=?");
$sth->execute($description,$classification_id); $sth->execute($description,$classification_id);
$vars->{'updated_description'} = 1; $vars->{'updated_description'} = 1;
unlink "$datadir/versioncache";
} }
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
LoadTemplate($action); LoadTemplate($action);
} }
......
...@@ -325,23 +325,18 @@ sub GetKeywordIdFromName { ...@@ -325,23 +325,18 @@ sub GetKeywordIdFromName {
$::VersionTableLoaded = 0; $::VersionTableLoaded = 0;
sub GetVersionTable { sub GetVersionTable {
return if $::VersionTableLoaded; return if $::VersionTableLoaded;
my $mtime = file_mod_time("$datadir/versioncache"); my $file_generated = 0;
if (!defined $mtime || $mtime eq "" || !-r "$datadir/versioncache") { if (!-r "$datadir/versioncache") {
$mtime = 0;
}
if (time() - $mtime > 3600) {
use Bugzilla::Token;
Bugzilla::Token::CleanTokenTable() if Bugzilla->dbwritesallowed;
GenerateVersionTable(); GenerateVersionTable();
$file_generated = 1;
} }
require "$datadir/versioncache"; require "$datadir/versioncache";
if (!defined %::versions) { if (!defined %::versions && !$file_generated) {
GenerateVersionTable(); GenerateVersionTable();
do "$datadir/versioncache"; do "$datadir/versioncache";
}
if (!defined %::versions) { if (!defined %::versions) {
die "Can't generate file $datadir/versioncache"; die "Can't generate file $datadir/versioncache";
}
} }
$::VersionTableLoaded = 1; $::VersionTableLoaded = 1;
} }
......
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