diff options
-rw-r--r-- | Bugzilla/Bug.pm | 16 | ||||
-rw-r--r-- | Bugzilla/DB/Schema.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 12 | ||||
-rw-r--r-- | Bugzilla/User.pm | 12 | ||||
-rw-r--r-- | template/en/default/admin/users/confirm-delete.html.tmpl | 11 |
5 files changed, 45 insertions, 9 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 26d2a89f3..42a7f7f15 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -2690,20 +2690,22 @@ sub add_comment { $params ||= {}; - # This makes it so we won't create new comments when there is nothing - # to add - if ($comment eq '' && !($params->{type} || abs($params->{work_time} || 0))) { - return; - } - # Fill out info that doesn't change and callers may not pass in $params->{'bug_id'} = $self; - $params->{'thetext'} = $comment; + $params->{'thetext'} = defined($comment) ? $comment : ''; # Validate all the entered data Bugzilla::Comment->check_required_create_fields($params); $params = Bugzilla::Comment->run_create_validators($params); + # This makes it so we won't create new comments when there is nothing + # to add + if ($params->{'thetext'} eq '' + && !($params->{type} || abs($params->{work_time} || 0))) + { + return; + } + # If the user has explicitly set remaining_time, this will be overridden # later in set_all. But if they haven't, this keeps remaining_time # up-to-date. diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 33527c367..6d9a33ef7 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -516,7 +516,8 @@ use constant ABSTRACT_SCHEMA => { FIELDS => [ user_id => {TYPE => 'INT3', REFERENCES => {TABLE => 'profiles', - COLUMN => 'userid'}}, + COLUMN => 'userid', + DELETE => 'SET NULL'}}, class => {TYPE => 'varchar(255)', NOTNULL => 1}, object_id => {TYPE => 'INT4', NOTNULL => 1}, field => {TYPE => 'varchar(64)', NOTNULL => 1}, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index cdd4f8e96..e8304cfbb 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -656,6 +656,9 @@ sub update_table_definitions { # 2011-06-15 dkl@mozilla.com - Bug 658929 _migrate_disabledtext_boolean(); + # 2011-10-11 miketosh - Bug 690173 + _on_delete_set_null_for_audit_log_userid(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -3607,6 +3610,15 @@ sub _rename_tags_to_tag { } } +sub _on_delete_set_null_for_audit_log_userid { + my $dbh = Bugzilla->dbh; + my $fk = $dbh->bz_fk_info('audit_log', 'user_id'); + if ($fk and !defined $fk->{DELETE}) { + $fk->{DELETE} = 'SET NULL'; + $dbh->bz_alter_fk('audit_log', 'user_id', $fk); + } +} + 1; __END__ diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index c4a042cf6..5b4f9a814 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -1764,6 +1764,18 @@ sub mail_settings { return $self->{'mail_settings'}; } +sub has_audit_entries { + my $self = shift; + my $dbh = Bugzilla->dbh; + + if (!exists $self->{'has_audit_entries'}) { + $self->{'has_audit_entries'} = + $dbh->selectrow_array('SELECT 1 FROM audit_log WHERE user_id = ? ' . + $dbh->sql_limit(1), undef, $self->id); + } + return $self->{'has_audit_entries'}; +} + sub is_insider { my $self = shift; diff --git a/template/en/default/admin/users/confirm-delete.html.tmpl b/template/en/default/admin/users/confirm-delete.html.tmpl index 1e7077eaf..8f1a3d2fc 100644 --- a/template/en/default/admin/users/confirm-delete.html.tmpl +++ b/template/en/default/admin/users/confirm-delete.html.tmpl @@ -226,7 +226,8 @@ [% IF assignee_or_qa || cc || component_cc || email_setting || flags.requestee || namedqueries || profile_setting || quips || series || watch.watched || - watch.watcher || whine_events || whine_schedules || other_safe %] + watch.watcher || whine_events || whine_schedules || otheruser.has_audit_entries || + other_safe %] <div class="warningmessages"> <p>The following deletions are <b>safe</b> and will not generate referential integrity inconsistencies.</p> @@ -427,6 +428,14 @@ but the whines themselves will be left unaltered. </li> [% END %] + [% IF otheruser.has_audit_entries %] + <li> + The user has performed audited administrative tasks + that are logged in the database. + If you delete this user account, the audit log entries + will no longer be indentifiable. + </li> + [% END %] [% Hook.process('warn_safe') %] </ul> </div> |