diff --git a/app/controllers/concerns/authentication_stages.rb b/app/controllers/concerns/authentication_stages.rb index 0322b6685b..947c7505e9 100644 --- a/app/controllers/concerns/authentication_stages.rb +++ b/app/controllers/concerns/authentication_stages.rb @@ -1,9 +1,9 @@ module Concerns module AuthenticationStages def stage_success - stage = session[:authentication_stages].first + stage = session[:authentication_stages]&.first - if stage.to_s == params[:stage] + if stage && stage.to_s == params[:stage] if params[:secret] == stage_secrets[stage] session[:authentication_stages] = session[:authentication_stages].drop(1) @@ -16,7 +16,7 @@ module Concerns else flash[:error] = I18n.t( :notice_auth_stage_wrong_stage, - expected: stage, + expected: stage || '(none)', actual: params[:stage] ) diff --git a/app/controllers/work_packages/moves_controller.rb b/app/controllers/work_packages/moves_controller.rb index 4514d54be5..de22ce1668 100644 --- a/app/controllers/work_packages/moves_controller.rb +++ b/app/controllers/work_packages/moves_controller.rb @@ -121,7 +121,7 @@ class WorkPackages::MovesController < ApplicationController def check_project_uniqueness unless @project # TODO: let users bulk move/copy work packages from different projects - render_error I18n.t('work_packages.move.unsupported_for_multiple_projects') + render_error message: :'work_packages.move.unsupported_for_multiple_projects', status: 400 return false end end diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb index df9fd2a994..a139d0c078 100644 --- a/app/controllers/work_packages_controller.rb +++ b/app/controllers/work_packages_controller.rb @@ -58,6 +58,10 @@ class WorkPackagesController < ApplicationController format.atom do atom_journals end + + format.all do + head :not_acceptable + end end end diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index 703839343e..a0aa1b194c 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -141,7 +141,9 @@ class Enumeration < ActiveRecord::Base # Does the +new+ Hash have the same custom values as the previous Enumeration? def self.same_custom_values?(new, previous) previous.custom_field_values.each do |custom_value| - if new && custom_value.value != new['custom_field_values'][custom_value.custom_field_id.to_s] + if new && + new['custom_field_values'] && + custom_value.value != new['custom_field_values'][custom_value.custom_field_id.to_s] return false end end diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 92702644a3..77fc3b40b5 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -79,6 +79,8 @@ module FileUploader def cache!(new_file = sanitized_file) super @old_tmp_file = new_file + rescue => e + Rails.logger.error "Failed cache! of temporary upload file: #{e}" end def delete_old_tmp_file(_dummy) diff --git a/modules/backlogs/lib/open_project/backlogs/burndown/series_raw_data.rb b/modules/backlogs/lib/open_project/backlogs/burndown/series_raw_data.rb index ff6db136f0..669e2b358a 100644 --- a/modules/backlogs/lib/open_project/backlogs/burndown/series_raw_data.rb +++ b/modules/backlogs/lib/open_project/backlogs/burndown/series_raw_data.rb @@ -103,7 +103,7 @@ module OpenProject::Backlogs::Burndown AND #{fixed_version_query} AND #{project_id_query} AND #{type_id_query} - AND #{status_query} + #{and_status_query} JOIN ( #{authoritative_journal_for_date(dates)} @@ -149,7 +149,7 @@ module OpenProject::Backlogs::Burndown AND #{fixed_version_query} AND #{project_id_query} AND #{type_id_query} - AND #{status_query}) + #{and_status_query}) GROUP BY CAST(j.created_at AS DATE), j.journable_type, @@ -173,7 +173,7 @@ module OpenProject::Backlogs::Burndown }.join(' UNION ') end - def status_query + def and_status_query @status_query ||= begin non_closed_statuses = Status.where(is_closed: false).select(:id).map(&:id) @@ -181,7 +181,11 @@ module OpenProject::Backlogs::Burndown open_status_ids = non_closed_statuses - done_statuses_for_project - "(#{Journal::WorkPackageJournal.table_name}.status_id IN (#{open_status_ids.join(',')}))" + if open_status_ids.empty? + '' + else + "AND (#{Journal::WorkPackageJournal.table_name}.status_id IN (#{open_status_ids.join(',')}))" + end end end diff --git a/modules/webhooks/app/workers/work_package_webhook_job.rb b/modules/webhooks/app/workers/work_package_webhook_job.rb index 3a1b9a8fe5..0ec3817b3c 100644 --- a/modules/webhooks/app/workers/work_package_webhook_job.rb +++ b/modules/webhooks/app/workers/work_package_webhook_job.rb @@ -30,6 +30,8 @@ require 'rest-client' #++ class WorkPackageWebhookJob < WebhookJob + include ::OpenProjectErrorHelper + attr_reader :webhook_id attr_reader :journal_id attr_reader :event_name @@ -46,21 +48,22 @@ class WorkPackageWebhookJob < WebhookJob body = request_body headers = request_headers exception = nil + response = nil if signature = request_signature(body) headers['X-OP-Signature'] = signature end - response = RestClient.post webhook.url, request_body, headers - rescue RestClient::Exception => e - response = e.response - - raise e - rescue => e - exception = e + begin + response = RestClient.post webhook.url, request_body, headers + rescue RestClient::Exception => e + response = e.response + exception = e + rescue StandardError => e + op_handle_error(e.message, reference: :webhook_job) + exception = e + end - raise e - ensure ::Webhooks::Log.create( webhook: webhook, event_name: event_name,