mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 14:26:04 +01:00
Fix "Page not found" error when saving workflows with many statuses on Rack >= 3.1.14 (#42875).
Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23841 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1,5 +1,16 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Rack 3.1.14 or later limits query parameters to 4096 by default, which
|
||||||
|
# prevents saving workflows with many statuses.
|
||||||
|
# Setting RACK_QUERY_PARSER_PARAMS_LIMIT to 65536 allows handling up to
|
||||||
|
# approximately 100 statuses.
|
||||||
|
#
|
||||||
|
# See also:
|
||||||
|
# - https://www.redmine.org/issues/42875
|
||||||
|
# - https://github.com/rack/rack/blob/v3.1.16/README.md#configuration
|
||||||
|
# - https://github.com/rack/rack/blob/v3.1.16/lib/rack/query_parser.rb#L57
|
||||||
|
ENV['RACK_QUERY_PARSER_PARAMS_LIMIT'] ||= '65536'
|
||||||
|
|
||||||
# Set up gems listed in the Gemfile.
|
# Set up gems listed in the Gemfile.
|
||||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,45 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
|||||||
assert w.assignee
|
assert w.assignee
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_post_edit_with_large_number_of_statuses
|
||||||
|
# This test ensures that workflows with many statuses can be saved.
|
||||||
|
# Without setting `ENV['RACK_QUERY_PARSER_PARAMS_LIMIT']`, this raises
|
||||||
|
# ActionController::BadRequest exception due to exceeding the default
|
||||||
|
# query parameter limit of 4096.
|
||||||
|
WorkflowTransition.delete_all
|
||||||
|
|
||||||
|
num_statuses = 40
|
||||||
|
transitions_data = {}
|
||||||
|
|
||||||
|
# Allowed statuses for a new issue (status_id = 0)
|
||||||
|
transitions_data['0'] = {}
|
||||||
|
(1..num_statuses).each do |status_id|
|
||||||
|
transitions_data['0'][status_id.to_s] = {'always' => '1'}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Status transitions between statuses
|
||||||
|
(1..num_statuses).each do |status_id_from| # rubocop:disable RuboCopStyle/CombinableLoops
|
||||||
|
transitions_data[status_id_from.to_s] = {}
|
||||||
|
(1..num_statuses).each do |status_id_to|
|
||||||
|
# skip self-transitions
|
||||||
|
next if status_id_from == status_id_to
|
||||||
|
|
||||||
|
transitions_data[status_id_from.to_s][status_id_to.to_s] = {
|
||||||
|
'always' => '1', 'author' => '1', 'assignee' => '1'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_nothing_raised do
|
||||||
|
patch :update, :params => {
|
||||||
|
:role_id => 2,
|
||||||
|
:tracker_id => 1,
|
||||||
|
:transitions => transitions_data
|
||||||
|
}
|
||||||
|
end
|
||||||
|
assert_response :found
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_permissions
|
def test_get_permissions
|
||||||
get :permissions
|
get :permissions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user