diff options
author | lpsolit%gmail.com <> | 2007-11-30 02:49:12 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2007-11-30 02:49:12 +0100 |
commit | f394b2ed4f175bf6076747ba7792e182841091ab (patch) | |
tree | d4ca1fcead500fd8edb40179e468423684fb7332 /Bugzilla/Install | |
parent | 5c9cb1c442e10faad5d5234f9c90f2a4529297be (diff) | |
download | bugzilla-f394b2ed4f175bf6076747ba7792e182841091ab.tar.gz bugzilla-f394b2ed4f175bf6076747ba7792e182841091ab.tar.xz |
Bug 99215: Attachments have no midair collision protection - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat r=justdave a=justdave
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 9934e058f..485c771b1 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -515,6 +515,9 @@ sub update_table_definitions { # 2007-08-21 wurblzap@gmail.com - Bug 365378 _make_lang_setting_dynamic(); + # 2007-09-09 LpSolit@gmail.com - Bug 99215 + _fix_attachment_modification_date(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -2898,6 +2901,31 @@ sub _make_lang_setting_dynamic { } } +sub _fix_attachment_modification_date { + my $dbh = Bugzilla->dbh; + if (!$dbh->bz_column_info('attachments', 'modification_time')) { + # Allow NULL values till the modification time has been set. + $dbh->bz_add_column('attachments', 'modification_time', {TYPE => 'DATETIME'}); + + print "Setting the modification time for attachments...\n"; + $dbh->do('UPDATE attachments SET modification_time = creation_ts'); + + # Now force values to be always defined. + $dbh->bz_alter_column('attachments', 'modification_time', + {TYPE => 'DATETIME', NOTNULL => 1}); + + # Update the modification time for attachments which have been modified. + my $attachments = + $dbh->selectall_arrayref('SELECT attach_id, MAX(bug_when) FROM bugs_activity + WHERE attach_id IS NOT NULL ' . + $dbh->sql_group_by('attach_id')); + + my $sth = $dbh->prepare('UPDATE attachments SET modification_time = ? + WHERE attach_id = ?'); + $sth->execute($_->[1], $_->[0]) foreach (@$attachments); + } +} + 1; __END__ |