public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Deprecate verification_timeout and verify before reset

Signed-off-by: Michael Koziarski <michael@koziarski.com>
Nick Sieger (author)
Thu Sep 04 05:03:19 -0700 2008
NZKoz (committer)
Thu Sep 04 05:36:09 -0700 2008
commit  7ba28726150f5d4ee3b3cb676d6b73cc3b62e186
tree    31080b916ee83653d58bc0d76397b28d884ae6d0
parent  f54be2cb3105856dc1fb31afc6c9012a91e53823
...
35
36
37
38
39
40
41
...
60
61
62
63
64
65
66
...
118
119
120
121
 
122
123
124
...
200
201
202
 
203
204
205
206
207
...
35
36
37
 
38
39
40
...
59
60
61
 
62
63
64
...
116
117
118
 
119
120
121
122
...
198
199
200
201
202
 
203
204
205
0
@@ -35,7 +35,6 @@ module ActiveRecord
0
     # * +wait_timeout+: number of seconds to block and wait for a connection
0
     #   before giving up and raising a timeout error (default 5 seconds).
0
     class ConnectionPool
0
-      delegate :verification_timeout, :to => "::ActiveRecord::Base"
0
       attr_reader :spec
0
 
0
       def initialize(spec)
0
@@ -60,7 +59,6 @@ module ActiveRecord
0
       # held in a hash keyed by the thread id.
0
       def connection
0
         if conn = @reserved_connections[current_connection_id]
0
-          conn.verify!(verification_timeout)
0
           conn
0
         else
0
           @reserved_connections[current_connection_id] = checkout
0
@@ -118,7 +116,7 @@ module ActiveRecord
0
       def verify_active_connections! #:nodoc:
0
         clear_stale_cached_connections!
0
         @connections.each do |connection|
0
-          connection.verify!(verification_timeout)
0
+          connection.verify!
0
         end
0
       end
0
 
0
@@ -200,8 +198,8 @@ module ActiveRecord
0
       end
0
 
0
       def checkout_and_verify(c)
0
+        c.verify!
0
         c.run_callbacks :checkout
0
-        c.verify!(verification_timeout)
0
         @checked_out << c
0
         c
0
       end
...
7
8
9
10
11
12
13
14
15
16
17
...
101
102
103
 
 
 
 
 
 
 
 
 
 
104
105
106
...
7
8
9
 
 
 
 
 
10
11
12
...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
0
@@ -7,11 +7,6 @@ module ActiveRecord
0
       end
0
     end
0
 
0
-    # Check for activity after at least +verification_timeout+ seconds.
0
-    # Defaults to 0 (always check.)
0
-    cattr_accessor :verification_timeout, :instance_writer => false
0
-    @@verification_timeout = 0
0
-
0
     # The connection handler
0
     cattr_accessor :connection_handler, :instance_writer => false
0
     @@connection_handler = ConnectionAdapters::ConnectionHandler.new
0
@@ -101,6 +96,16 @@ module ActiveRecord
0
         ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency= has been deprecated and no longer has any effect. Please remove all references to allow_concurrency=.")
0
       end
0
 
0
+      # Deprecated and no longer has any effect.
0
+      def verification_timeout
0
+        ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout has been deprecated and no longer has any effect. Please remove all references to verification_timeout.")
0
+      end
0
+
0
+      # Deprecated and no longer has any effect.
0
+      def verification_timeout=(flag)
0
+        ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout= has been deprecated and no longer has any effect. Please remove all references to verification_timeout=.")
0
+      end
0
+
0
       # Returns the connection currently associated with the class. This can
0
       # also be used to "borrow" the connection to do database work unrelated
0
       # to any of the specific Active Records.
...
123
124
125
126
127
128
129
130
131
132
133
 
 
 
 
134
135
136
...
123
124
125
 
 
 
 
 
 
 
 
126
127
128
129
130
131
132
0
@@ -123,14 +123,10 @@ module ActiveRecord
0
         false
0
       end
0
 
0
-      # Lazily verify this connection, calling <tt>active?</tt> only if it
0
-      # hasn't been called for +timeout+ seconds.
0
-      def verify!(timeout)
0
-        now = Time.now.to_i
0
-        if (now - @last_verification) > timeout
0
-          reconnect! unless active?
0
-          @last_verification = now
0
-        end
0
+      # Verify this connection by calling <tt>active?</tt> and reconnecting if
0
+      # the connection is no longer active.
0
+      def verify!(*ignored)
0
+        reconnect! unless active?
0
       end
0
 
0
       # Provides access to the underlying database connection. Useful for
...
880
881
882
883
 
884
885
886
...
880
881
882
 
883
884
885
886
0
@@ -880,7 +880,7 @@ class BasicsTest < ActiveRecord::TestCase
0
 
0
   def test_mass_assignment_protection_against_class_attribute_writers
0
     [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging,
0
-      :default_timezone, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method|
0
+      :default_timezone, :schema_format, :lock_optimistically, :record_timestamps].each do |method|
0
       assert  Task.respond_to?(method)
0
       assert  Task.respond_to?("#{method}=")
0
       assert  Task.new.respond_to?(method)
...
24
25
26
27
 
28
29
30
...
24
25
26
 
27
28
29
30
0
@@ -24,7 +24,7 @@ class MysqlConnectionTest < ActiveRecord::TestCase
0
     assert @connection.active?
0
     @connection.update('set @@wait_timeout=1')
0
     sleep 2
0
-    @connection.verify!(0)
0
+    @connection.verify!
0
     assert @connection.active?
0
   end
0
 end

Comments