なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2020/05/05)

2020/05/05分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md


Remove hashing from secure_compare and clarify documentation

activesupport/lib/active_support/security_utils.rbの修正です.

secure_compareメソッドでfixed_length_secure_compareを呼び出す際にハッシュ化していたのを削除しています。

ハッシュ化だと文字列の内容の推測を防ぐ事は出来るが文字列の長さの推測を防ぐ事が出来ず(ハッシュ化の実行が文字列の長さに依存する為)ハッシュ化してもセキュリティ上のメリットが無いため、代わりに長さでのチェックを行うようにした、との事です。


Add a separator to the cache key for ActiveSupport::CachingKeyGenerator

activesupport/lib/active_support/key_generator.rbの修正です。

ActiveSupport::CachingKeyGeneratorのcache keyにセパレータを追加するよう修正しています。

このcache keyはsaltとkey lengthを単純に連結している為、例えば、@caching_generator.generate_key("133", 7)@caching_generator.generate_key("13", 37)で同じkey(1337)が生成されてしまっていまい、後者の場合に想定通りのkey lengthにならない、という問題がありました。で、これを避ける為に、saltとkey lengthの間にセパレータを追加し対応しています。


Style fix for CachingKeyGenerator

activesupport/lib/active_support/key_generator.rbの修正です。

rubocopの設定に違反している箇所があったのを修正しています


Inspect time attributes with subsec

activerecord/lib/active_record/attribute_methods.rbの修正です。

Active Recordのtime attributesのinspect結果にsubsecの値も含むよう修正しています。


Fix flakey destroyed_by_association tests

activerecord/test/cases/associations/has_one_associations_test.rbの修正です。

destroyed_by_associationテストで想定外のデータが削除されてしまうのを避ける為に、明示的にfixtureで必要なデータをロードするよう修正しています。


Remove obsolete explain logging test

activerecord/test/cases/explain_test.rbの修正です。

既に削除済みのauto-explainの為のテストが残っていたのを削除しています。


Include parallelize :threads option when fork is not available

railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.ttの修正です。

rails newで生成されるtest_helper.rbに、forkが使えない環境ではparallelizeにスレッドオプションを指定するよう修正しています。


Fix rewhere to truly overwrite collided where clause by new where clause

activerecord/lib/active_record/relation/query_methods.rbactiverecord/lib/active_record/relation/where_clause.rbの修正です。

rewhereで指定したconditionで元のwhereのconditionが正しくオーバーライトされないケースがあったのを修正しています。


Merge pull request #39051 from kamipo/more_concise_or_ast

activerecord/lib/active_record/relation/where_clause.rbactiverecord/lib/arel/visitors/to_sql.rbの修正です。

orを1000回呼び出すと、"Stack level too deep"が発生してしまうバグがあったのを修正しています。


Merge pull request #39022 from kamipo/perf_where_in

Active Recordの修正です。

wherevalueのArrayを指定した場合にオブジェクトの生成数を減らせるようリファクタリングしています。


Remove deprecated ActionMailer::Base.receive in favor of Action Mailbox

Action Mailerの修正です。

deprecateになっていたActionMailer::Base.receiveメソッドを削除しています。


Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob

Action Mailerの修正です。

deprecateになっていたActionMailer::DeliveryJobActionMailer::Parameterized::DeliveryJobを削除しています。


Remove deprecated force_ssl at the controller level.

Action Packの修正です。

deprecateになっていたcontrollerレベルでのforce_sslを削除しています。


Remove unneeded test after force_ssl removal

railties/test/application/configuration_test.rbの修正です。

先程削除したcontrollerレベルでのforce_sslに関するテストが残っていたのを削除しています。


Deprecate starts_with? and ends_with? for String core extensions

Active Supportの修正です。

String#starts_with?及びString#ends_with?メソッドをdeprecateにしています。

Ruby本体に同等のメソッド(start_with? / end_with?)がある、かつ、starts_with? / ends_with?を使用するとSymbol#start_with? / Symbol#end_with?がある事のメリットをうけられない、という理由によりdeprecateになりました。

が、merge後にちょっと議論が発生し、String#starts_with?及びString#ends_with?はそのままとなる事になりました。


save and save! doesn't take positional arguments

Active Recordの修正です。

savesave!メソッドのシグネチャが、positional引数とkeyword引数両方を受け取れるようになっていたのですが、savesave!はpositional引数はそもそも受け取られない為、不要なシグネチャを削除しています。


Relax required rack-mini-profiler version 2.0.x to 2.x

railties/lib/rails/generators/rails/app/templates/Gemfile.ttの修正です。

rails newで生成されるGemfileで、rack-mini-profilerのバージョン指定が~> 2.0.0になっていたのを、~> 2.0に修正しています。


Follow up to #38953 [ci skip]

rails guideの修正です。

config.load_defaultsに指定する値がStringになっていたのを、rails newで実際に生成される内容に合わせてFloatを使用するよう修正しています。


Follow up to 3f27aa8cdf8c3c7f36d630f0241854f712e4c937

activesupport/lib/active_support/cache.rbの修正です。

キーワード引数を受け取れないsave_block_result_to_cacheメソッドのシグネチャ**が指定されていたのを削除しています。


Type::Value#initialize doesn't take positional arguments

activemodel/lib/active_model/type/integer.rbの修正です。

Type::Value#initializeメソッドのシグネチャが、positional引数とkeyword引数両方を受け取れるようになっていたのですが、positional引数は受け取られない為不要なシグネチャを削除しています。


Avoid synchronize { } call only for MRI

actionpack/lib/action_dispatch/http/response.rbactiverecord/lib/active_record/connection_adapters/abstract/connection_pool.rbの修正です。

変数参照時にsynchronizeを使用するかどうかのチェックを、JRUBY_VERSIONが定義されているかどうかでチェックしていたのを、MRIの場合のみsynchronizeを使用しないよう修正しています。


Use the file_fixture_path for fixture_file_upload:

actionpack/lib/action_dispatch/testing/test_process.rbの修正です。

fixture_file_uploadメソッドがファイルを検索するのに、fixture_path相対パスで検索していたのがdeprecateになりました。今後はfile_fixture_path相対パスで検索されるようになります。

fixture_pathはActive Recordの為の値であり、file_fixture_pathがある今Action Packでfixture_pathを使うのは良くないのでは、という事でdeprecateになりました。


Revert "Merge pull request #39152 from kamipo/deprecate_starts_ends_with"

String#starts_with?及びString#ends_with?メソッドをdeprecateにした、Deprecate starts_with? and ends_with? for String core extensionsをRevertしています。