Merge branch 'jbrowning-fix_mariadb_rename_index'

Closes #15936

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Merge pull request #16954 from geoffharcourt/inject-over-sum

Use #inject over #sum to build PG create DB statement
Merge pull request #16936 from untidy-hair/plugin_test_db_migrate_path

Specify dummy app's db migrate path in plugin's test_helper.rb

Conflicts:
	railties/CHANGELOG.md

Conflicts:
	railties/CHANGELOG.md
inject Rack::Lock if config.eager_load is false

If code is not eager loaded constants are loaded on demand. Constant
autoloading is not thread-safe, so if eager loading is not enabled
multi-threading should not be allowed.

This showed up in certain Capybara scenarios: Most Capybara drivers
other than Rack::Test need a web server. In particular, drivers for
JavaScript support. Capybara launches WEBrick in its own thread for
those but that per se is fine, because the spec thread and the server
thread are coordinated.

Problem comes if the page being served in the spec makes Ajax calls.
Those may hit WEBrick in parallel, and since WEBrick is multi-threaded
and allow_concurrency? returns true in the test environment before
this patch, threads are spawned to serve those parallel requests. On
the other hand, since eager_load is false by default in the test
environment, constants are not preloaded.

So the suite is autoloading constants in a multi-threaded set. That's
a receipt for paracetamol. The symptom is random obscure errors whose
messages point somehow to constant autoloading.

As a consequence of this fix for allow_concurrency? WEBrick in
Capybara scenarios no longer runs in multi-threaded mode.

Fixes #15089.

Conflicts:
	railties/CHANGELOG.md
Revert "inject Rack::Lock if config.eager_load is false"

After some discussion in Campfire we have decided to revert this one.
There are legit use cases where concurrent but coordinated requests
are made.

We have seen a test suite that uses Rack::Reproxy to redispatch
requests down, and also some actions that call un-mocked services
that call the original app and need to complete the cycle to
complete the original request.

While this is a more sane default for 4.2, its backport is more
dubious because it would break those test suites.

As a workaround, people having issues related to this before 4.2 can
throw

    config.allow_concurrency = false

in config/environments/test.rb.

This reverts commit 65f75c0ceadac0080a576c1a4551b7c55f4bdff6.
Merge pull request #16974 from silp-com/mail_was_called

ActionMailer: mark mail as called after instead of before processing it

Conflicts:
	actionmailer/CHANGELOG.md
always reorder bind parameters. fixes #15920

Conflicts:
	activerecord/lib/active_record/relation/query_methods.rb
Merge pull request #17145 from mrbrdo/issue15920-4-1

always reorder bind parameters. fixes #15920
Merge pull request #17221 from StefanH/fix-unknown-http-method-message

Invalid HTTP method will raise I18n::InvalidLocale if :en is not a valid locale.
Merge pull request #17240 from masarakki/fix-test_helper-of-mountable-plugin

fix test_helper for mountable plugin
Fix regression where router was overwriting PATH_INFO

on cda64c834bb98a2213f57d57efc40afd6ca527ad `path_info` variable already
existed before, so we are overwriting its value.
Add regression test and rename the variable.

[fixes #16926]
[related #17035]
Merge pull request #17233 from arthurnn/fix_regression_on_path_and_cascade

Fix regression where router was overwriting PATH_INFO
Don't need to account turbolinks cookies in get request.

It was changed to not set the cookie in get requests at
https://github.com/rails/turbolinks/commit/62cc3db457ad9745ccda047dd43ab84fb3d89707.

Related with dcb05f26.
Merge pull request #17255 from printercu/cors_exception_wrapper

ActionController::InvalidCrossOriginRequest fails with 422 instead of 500
Merge pull request #17313 from accessd/fix-url-generation-error-message

Fix url generation error message
Clarify comments in sanitize_helper.rb

Arguments passed to methods like `sanitized_allowed_tags=` should be Enumerable, so the examples have been wrapped in square brackets to suggest this explicitly.
Merge pull request #17390 from MCGallaspy/issue-17386

Clarify comments in sanitize_helper.rb [ci skip]
Merge pull request #17064 from frenkel/fix_select_tag_include_blank

Use include_blank value as option label
Properly quote numerics when casting string columns

Returning the wrong type can cause the wrong index to be used on some
adapters, or even an error. We use `.try` rather than checking for
`nil`, since the tests on 4.1 imply that objects that do not respond to
`type` can be passed as the column for `quote`.

Closes #17345
Update documentation of touch method

- Note that after_commit and after_rollback callbacks are also run.
- This documentation update is present in master but not in rails-4-1 branch.
- Closes #17438
[ci skip]