なるようになるブログ

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

rails commit log流し読み(2016/10/03)

2016/10/03分のコミットです。

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

actionpack/CHANGELOG.md

railties/CHANGELOG.md


Revert "Merge pull request #26677 from tbalthazar/26644"

ActiveSupport::TimeWithZone#localtimeメソッドで値をキャッシュする際、utc_offset毎に値をキャッシュするようにした対応(Merge pull request #26677 from tbalthazar/26644 · rails/rails@9ce2d1bをrevertしています。

引数と合わせてlocaltimeの情報をActiveSupport::TimeWithZone#localtimeメソッドでキャッシュするのは困難(Time Zone環境変数が変わった場合に、値のキャッシュを正しく行えないもよう)な為、ActiveSupport::TimeWithZone#localtimeでキャッシュするのではなく、DateAndTime::Compatibility#to_timeでキャッシュするようにするとの事です。


Revert "Merge pull request #25880 from ryandv/fix_performance_regression_in_timewithzone_to_time"

ActiveSupport::TimeWithZone#localtimeメソッドで値をキャッシュするよう修正した対応(Merge pull request #25880 from ryandv/fix_performance_regression_in_timewithzone_to_time)をrevertしています。理由は先程のrevertと同様。


Cache to_time to improve performance when comparing

activesupport/lib/active_support/core_ext/date_and_time/compatibility.rbの修正です。

DateAndTime::Compatibility#to_timelocaltimeの情報を保持するよう修正しています。性能向上の為。

    def to_time
-      preserve_timezone ? getlocal(utc_offset) : getlocal
+      if preserve_timezone
+        @_to_time_with_instance_offset ||= getlocal(utc_offset)
+      else
+        @_to_time_with_system_offset ||= getlocal
+      end
     end

Merge pull request #26620 from maclover7/jm-ac-pg-bug

actioncable/lib/action_cable/server/base.rbの修正です。

Action Cableでclassのreloadを行う際に、pubsub connectionのshutdownを行うよう修正しています。

classのreloadを行った際、Active Recordではactiveなconnectionを全てclearするのですが、Action Cableではclass reload後もそのclearされたconnectionをそのまま利用しようとしてエラーになっていました。

そのため、class reload後に再度connectionの取得を行うよう、pubsub のshutdownを行うようにしたとの事です。


Shut down the worker pool - don't kill it

actioncable/lib/action_cable/server/worker.rbの修正です。

ActionCable::Server::Worker#haltメソッドでworker poolをkillしていたのを、shutdownするよう修正しています。

      def halt
-        @executor.kill
+        @executor.shutdown
       end

@executorConcurrent::ThreadPoolExecutorクラスのインスンタンスなのですが、Concurrent::ThreadPoolExecutorのドキュメント(メソッドの実装はRubyThreadPoolExecutor)を見る限り、即時削除かどうかの違いがあるようです。

参考:Class: Concurrent::RubyThreadPoolExecutor — Documentation for ruby-concurrency/concurrent-ruby (master)


Merge pull request #26425 from prathamesh-sonpatki/fix-nil-issue

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

ActiveRecord::Integration#cache_keyメソッドで、引数(timestamp_names)を指定している、かつ、その指定したtimestampカラムがnilだった場合に、model name + idの値を返すよう修正しています。


Temporarily make ACa tests noiser and more predictable

.travis.ymlの修正です。

Action Cableのテストを実行する際、verbose、及びseedオプションを指定するよう修正しています。

seedを固定化して一時的にテストを安定化させる為、のようです。


Show an "unmatched constraints" error for mismatching and present params

actionpack/lib/action_dispatch/journey/formatter.rbactionpack/lib/action_dispatch/routing/route_set.rbの修正です。

routesでconstraintsを使用している、かつ、constraintsにマッチしない値をpath helperメソッドを指定した場合に、エラーメッセージがmissing required keysとなっていたのを、possible unmatched constraintsになるよう修正しています。

# before
resources :reports, only: [:new, :create, :show], param: :reference, reference: /\d+/
report_path(reference: "ABC123")
# => ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"reports", :reference=>"ABC123"} missing required keys: [:reference]


# after
resources :reports, only: [:new, :create, :show], param: :reference, reference: /\d+/
report_path(reference: "ABC123")
# => ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"reports", :reference=>"ABC123"}, possible unmatched constraints: [:reference]

Allow the use of listen's 3.1.x branch.

Gemfilerailties/lib/rails/generators/rails/app/templates/Gemfileの修正です。

rails newした際に生成されるGemfile及びRails本体で使用しているGemfileで、listen3.0系しか使えないようになっていたのを、3.1系も使用出来るよう制限を緩和しています。