/** * Update a bug from the given data structure * If the third parameter is true, also update the longer strings table * @param boolean $p_update_extended Whether to update extended fields. * @param boolean $p_bypass_mail Whether to bypass sending email notifications. * @internal param boolean $p_bypass_email Default false, set to true to avoid generating emails (if sending elsewhere) * @return boolean (always true) * @access public */ function update($p_update_extended = false, $p_bypass_mail = false) { self::validate($p_update_extended); $c_bug_id = $this->id; if (is_blank($this->due_date)) { $this->due_date = date_get_null(); } $t_old_data = bug_get($this->id, true); # Update all fields # Ignore date_submitted and last_updated since they are pulled out # as unix timestamps which could confuse the history log and they # shouldn't get updated like this anyway. If you really need to change # them use bug_set_field() $t_query = 'UPDATE {bug} SET project_id=' . db_param() . ', reporter_id=' . db_param() . ', handler_id=' . db_param() . ', duplicate_id=' . db_param() . ', priority=' . db_param() . ', severity=' . db_param() . ', reproducibility=' . db_param() . ', status=' . db_param() . ', resolution=' . db_param() . ', projection=' . db_param() . ', category_id=' . db_param() . ', eta=' . db_param() . ', os=' . db_param() . ', os_build=' . db_param() . ', platform=' . db_param() . ', version=' . db_param() . ', build=' . db_param() . ', fixed_in_version=' . db_param() . ','; $t_fields = array($this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $this->status, $this->resolution, $this->projection, $this->category_id, $this->eta, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->fixed_in_version); $t_roadmap_updated = false; if (access_has_project_level(config_get('roadmap_update_threshold'))) { $t_query .= ' target_version=' . db_param() . ','; $t_fields[] = $this->target_version; $t_roadmap_updated = true; } $t_query .= ' view_state=' . db_param() . ', summary=' . db_param() . ', sponsorship_total=' . db_param() . ', sticky=' . db_param() . ', due_date=' . db_param() . ' WHERE id=' . db_param(); $t_fields[] = $this->view_state; $t_fields[] = $this->summary; $t_fields[] = $this->sponsorship_total; $t_fields[] = (bool) $this->sticky; $t_fields[] = $this->due_date; $t_fields[] = $this->id; db_query($t_query, $t_fields); bug_clear_cache($this->id); # log changes history_log_event_direct($c_bug_id, 'project_id', $t_old_data->project_id, $this->project_id); history_log_event_direct($c_bug_id, 'reporter_id', $t_old_data->reporter_id, $this->reporter_id); history_log_event_direct($c_bug_id, 'handler_id', $t_old_data->handler_id, $this->handler_id); history_log_event_direct($c_bug_id, 'priority', $t_old_data->priority, $this->priority); history_log_event_direct($c_bug_id, 'severity', $t_old_data->severity, $this->severity); history_log_event_direct($c_bug_id, 'reproducibility', $t_old_data->reproducibility, $this->reproducibility); history_log_event_direct($c_bug_id, 'status', $t_old_data->status, $this->status); history_log_event_direct($c_bug_id, 'resolution', $t_old_data->resolution, $this->resolution); history_log_event_direct($c_bug_id, 'projection', $t_old_data->projection, $this->projection); history_log_event_direct($c_bug_id, 'category', category_full_name($t_old_data->category_id, false), category_full_name($this->category_id, false)); history_log_event_direct($c_bug_id, 'eta', $t_old_data->eta, $this->eta); history_log_event_direct($c_bug_id, 'os', $t_old_data->os, $this->os); history_log_event_direct($c_bug_id, 'os_build', $t_old_data->os_build, $this->os_build); history_log_event_direct($c_bug_id, 'platform', $t_old_data->platform, $this->platform); history_log_event_direct($c_bug_id, 'version', $t_old_data->version, $this->version); history_log_event_direct($c_bug_id, 'build', $t_old_data->build, $this->build); history_log_event_direct($c_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $this->fixed_in_version); if ($t_roadmap_updated) { history_log_event_direct($c_bug_id, 'target_version', $t_old_data->target_version, $this->target_version); } history_log_event_direct($c_bug_id, 'view_state', $t_old_data->view_state, $this->view_state); history_log_event_direct($c_bug_id, 'summary', $t_old_data->summary, $this->summary); history_log_event_direct($c_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $this->sponsorship_total); history_log_event_direct($c_bug_id, 'sticky', $t_old_data->sticky, $this->sticky); history_log_event_direct($c_bug_id, 'due_date', $t_old_data->due_date != date_get_null() ? $t_old_data->due_date : null, $this->due_date != date_get_null() ? $this->due_date : null); # Update extended info if requested if ($p_update_extended) { $t_bug_text_id = bug_get_field($c_bug_id, 'bug_text_id'); $t_query = 'UPDATE {bug_text} SET description=' . db_param() . ', steps_to_reproduce=' . db_param() . ', additional_information=' . db_param() . ' WHERE id=' . db_param(); db_query($t_query, array($this->description, $this->steps_to_reproduce, $this->additional_information, $t_bug_text_id)); bug_text_clear_cache($c_bug_id); $t_current_user = auth_get_current_user_id(); if ($t_old_data->description != $this->description) { if (bug_revision_count($c_bug_id, REV_DESCRIPTION) < 1) { bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_DESCRIPTION, $t_old_data->description, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_DESCRIPTION, $this->description); history_log_event_special($c_bug_id, DESCRIPTION_UPDATED, $t_revision_id); } if ($t_old_data->steps_to_reproduce != $this->steps_to_reproduce) { if (bug_revision_count($c_bug_id, REV_STEPS_TO_REPRODUCE) < 1) { bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_STEPS_TO_REPRODUCE, $t_old_data->steps_to_reproduce, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $this->steps_to_reproduce); history_log_event_special($c_bug_id, STEP_TO_REPRODUCE_UPDATED, $t_revision_id); } if ($t_old_data->additional_information != $this->additional_information) { if (bug_revision_count($c_bug_id, REV_ADDITIONAL_INFO) < 1) { bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_ADDITIONAL_INFO, $t_old_data->additional_information, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $this->additional_information); history_log_event_special($c_bug_id, ADDITIONAL_INFO_UPDATED, $t_revision_id); } } # Update the last update date bug_update_date($c_bug_id); # allow bypass if user is sending mail separately if (false == $p_bypass_mail) { # If handler changes, send out owner change email if ($t_old_data->handler_id != $this->handler_id) { email_owner_changed($c_bug_id, $t_old_data->handler_id, $this->handler_id); return true; } # status changed if ($t_old_data->status != $this->status) { $t_status = MantisEnum::getLabel(config_get('status_enum_string'), $this->status); $t_status = str_replace(' ', '_', $t_status); email_bug_status_changed($c_bug_id, $t_status); return true; } # @todo handle priority change if it requires special handling email_bug_updated($c_bug_id); } return true; }
# that custom functions are being deprecated in MantisBT. You should migrate to # the new plugin system instead. helper_call_custom_function('issue_update_notify', array($f_bug_id)); # Send a notification of changes via email. if ($t_resolve_issue) { email_resolved($f_bug_id); email_relationship_child_resolved($f_bug_id); } else { if ($t_close_issue) { email_close($f_bug_id); email_relationship_child_closed($f_bug_id); } else { if ($t_reopen_issue) { email_bug_reopened($f_bug_id); } else { if ($t_existing_bug->handler_id !== $t_updated_bug->handler_id) { email_owner_changed($f_bug_id, $t_existing_bug->handler_id, $t_updated_bug->handler_id); } else { if ($t_existing_bug->status !== $t_updated_bug->status) { $t_new_status_label = MantisEnum::getLabel(config_get('status_enum_string'), $t_updated_bug->status); $t_new_status_label = str_replace(' ', '_', $t_new_status_label); email_bug_status_changed($f_bug_id, $t_new_status_label); } else { email_bug_updated($f_bug_id); } } } } } form_security_purge('bug_update'); print_successful_redirect_to_bug($f_bug_id);