culturecode_stagehand 0.14.3 → 0.14.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 057a8710cbdfb48d9e7214e04f9dd9b506d18caf
4
- data.tar.gz: 300b3dd8173a519ad7f8c492c1362bf0e939b8e9
3
+ metadata.gz: e0691ceae72d5001db6bd38f259157f4a82dff1e
4
+ data.tar.gz: 09816a1e820606659d76695e32854109979e024a
5
5
  SHA512:
6
- metadata.gz: 2030b34bb3b871e5498bc1b9a4be1e757d07978f34c9106f2456fffdd7e0677f96eb526a72dc5fe2cf42bb8d3e97f6f0aae857cd4dd65e97cbe2f30e5bc03f56
7
- data.tar.gz: d796af03288f26476ef2d8bac65ead9996ca22a94627eabab589e34eeb19fdc2552ce2fd27388eb7f6c02aa08b5745384bee276c021e06d897c94d706de5a662
6
+ metadata.gz: dbe697859ad03c61ece9f6f0e986933dcb6266f86eeecc6d3a13c3775ae1d8063c5721888637055f8bf93ef5099d384d2ea6ee0e5d937001f4cc87f2da2f2100
7
+ data.tar.gz: 68dbd5120d87b68da524d3de44d77368ce810ca1a205ab6cc73d0ac5b5ae0702f89750f58068a215642aa871ad4796dde4701bfa0484159fbbd0a1240acd0976
@@ -102,8 +102,8 @@ module Stagehand
102
102
  return unless entries.present?
103
103
 
104
104
  Database.transaction do
105
- # Lock the records so nothing can update them
106
- CommitEntry.connection.execute(CommitEntry.where(:id => entries).lock.to_sql)
105
+ # Lock the records so nothing can update them after we confirm autosyncability
106
+ acquire_record_locks(entries)
107
107
 
108
108
  # Execute the block for each entry we've confirm autosyncability
109
109
  confirmed_ids = Set.new(autosyncable_entries.where(:id => entries).pluck(:id))
@@ -114,6 +114,12 @@ module Stagehand
114
114
  end
115
115
  end
116
116
 
117
+ # Does not actually acquire a lock, instead it triggers a 'first read' so the transaction will ensure subsequent
118
+ # reads of the locked rows return the same value, even if modified outside of the transaction
119
+ def acquire_record_locks(entries)
120
+ entries.each(&:record)
121
+ end
122
+
117
123
  def autosyncable_entries(scope = nil)
118
124
  entries = CommitEntry.content_operations.not_in_progress.where(scope)
119
125
  entries = entries.with_uncontained_keys unless Configuration.ghost_mode?
@@ -143,7 +149,7 @@ module Stagehand
143
149
 
144
150
  def run_sync_callbacks(entry, callbacks, &block)
145
151
  callbacks = Array.wrap(callbacks).dup
146
- return block.call unless entry.record && callbacks.present?
152
+ return block.call unless callbacks.present? && entry.record
147
153
 
148
154
  entry.record.run_callbacks(callbacks.shift) do
149
155
  run_sync_callbacks(entry, callbacks, &block)
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.14.3"
2
+ VERSION = "0.14.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturecode_stagehand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.3
4
+ version: 0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-25 00:00:00.000000000 Z
12
+ date: 2017-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails