なるようになるブログ

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

rails commit log流し読み(2019/02/05)

2019/02/05分のコミットです。

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

activesupport/CHANGELOG.md

actionpack/CHANGELOG.md


Merge pull request #35086 from gsamokovarov/cleanup-whitelisting-refs

Action Pack、railtiesの修正です。

Host Authorization機能のdoc、testで"whitelist"という単語を使用していたのを、permit等他の単語を使用するよう修正しています。

参考:Replace use of whitelist with allowlist and blacklist with denylist


Add a link to where "inquiry" is defined in ActiveSupport docs

rails guideのActive Support Core Extensionsの修正です。

inquiryメソッドについて説明している箇所に、メソッドが定義されているファイル名を記載するよう修正しています。


Merge pull request #35134 from Edouard-chin/ec-cookie-expiry-regression

actionpack/lib/action_dispatch/middleware/cookies.rbの修正です。

use_cookies_with_metadataにtrueが設定されていない場合に、cookieがexpireしないバグがあったのを修正しています。


Relax sqlite3 version dependency

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rbGemfileの修正です。

sqlite3 gemのバージョンが1.3系に固定されていたのを、1系を使用出来るようバージョン指定を修正しています。

sqlite3 1.4がリリースされており、そちらを使用出来るようにするため。


Improve performance of blank? and present? in an ActiveRecord::Base instance

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

ActiveRecord::Baseblank?、及び、present?メソッドを定義しています。

元々、上記メソッドは結果を取得する為に大量のメソッド呼び出しが発生し、処理が遅い、という問題がありました。ただ、結果はわかっている(present?はtrue、blank?はfalse)になるべきなので、処理高速化の為にそれぞれのメソッドを定義するよう修正しています。

参考:Implement blank? and present? directly in ActiveRecord::BaseDefine Model#present? and Model#blank? methods


Take in to account optional arguments when deprecating

actionview/lib/action_view/template/handlers.rbの修正です。

ActionView::Template.register_template_handlerの第二引数にoptional argumentsを指定した場合に、deprecate warningが出ていたのを、出ないよう修正しています。これが出るのは想定外(実装漏れ)のため。


Specify sqlite gem version explicitly in version-specific bug report templates

guides/bug_report_templates/active_record_gem.rbguides/bug_report_templates/active_record_migrations_gem.rbの修正です。

bug report templatesでsqlite3 gemのバージョンを指定するよう修正しています。リリースされているgemだと、sqlite3 1.4系と動作しない為。


Merge pull request #35063 from rosa/current-before-reset-callback

ActiveSupport::CurrentAttributes classにbefore_resetメソッド(内容はメソッド名の通りresetの前に実行される処理)を追加しています。

元々resetsメソッドがあったのですが、こちらはresetの後に実行される処理を指定する為のメソッドのため、この対応で合わせてresetsのaliasとしてafter_resetメソッドを追加しています。


Update Gemfile.lock to reflect sqlite3 update

Gemfile.lockの修正です。

先のsqlite3のバージョンロック修正の際に、Gemfile.lockの更新が漏れていたのを対応しています。


Match rails generator output

actioncable/lib/rails/generators/channel/templates/javascript/consumer.js.ttの修正です。

Action Cable generatorが生成するsampleファイルの内容が、rails newで生成するファイルの内容と異なってしまっていたのを、同じ内容を生成するよう修正しています。


Use ES6 short style

actioncable/lib/rails/generators/channel/templates/javascript/channel.js.ttの修正です。

Action Cable generatorが生成するsampleファイルから、不要なfunctionの宣言を削除しています。


Bugfix association loading behavior when counter cache is zero

activerecord/lib/active_record/associations/collection_association.rbactiverecord/lib/active_record/associations/has_many_association.rbの修正です。

counter cacheを使用している、かつ、counter cacheの値が0の時に、メソッドの呼び出し順により、本来queryを実行すべきではないメソッドで(ロード済みのレコードが使用されるべき)でqueryが実行されてしまう、というバグがあったのを修正しています。


Merge pull request #35139 from 7coAim/fix_debug_exceptions

actionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erbactionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erbの修正です。

invalid statementが発生した際に使用するdebug exceptionのtemplateファイルで、エラーが発生した箇所がActive Storageのtableかどうかを判定する前に、ActiveStorageが定義されているかどうかをチェックするよう修正しています。

ActiveStorageが定義されていない場合、tableのチェック処理で違うエラーになってしまう為。


Improve regexp of html_safe_translation_key?

actionview/lib/action_view/helpers/translation_helper.rbの修正です。

TranslationHelper#html_safe_translation_key?メソッドの正規表現について、終端チェックに$ではなく\zを使用する、alternationではなくcharacter classを使用する等の改善を行っています。


Respect ENV variables when finding DBs etc for the test suite

テストの修正です。

テスト無いでRedis、memcache等のサービスに接続する際に、接続先を環境変数で指定出来るよう修正しています。