infopark_reactor 1.20.0 → 1.20.1

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: 4565152e9620ee1549db9c630f29fc09963aca7c
4
- data.tar.gz: 2f73a2ba9c91bf01bb6e976c5dc3f7c95ae69131
3
+ metadata.gz: 454dbe710b4633a4ed51766bbff6715c3fc61389
4
+ data.tar.gz: 9bfab36ff12db044a67d43bb2af6949064621d86
5
5
  SHA512:
6
- metadata.gz: ea47b54ec12a7c0d158194e00af28291028d63a9873fb88b66cf881891ed1f55ea3ab26709aa7741f45eeaf79bf6aa16b255170a0b5e9ad39fc04e80639aff04
7
- data.tar.gz: 666ca185f3ff1ecbbc9fc489c37c88e2cfa7be23c48e2fa4da3aa9de8408635f7641dad6fb308bc6d2c2e521a328cadf93766abc55310afb06d3237c05abed37
6
+ metadata.gz: 544e8f98979aa61bd01a1b67452c52f33fc46c4acd75ec3120266556b083aba990ba191244f9bc6fba7e43a3a2ea92471bfc8fde8b0dea4fbe129379e3e09d0d
7
+ data.tar.gz: 22bad39cdab60ca1d9ce6ab0dac9a4a0d67e788a189c22ab883e279689d60500fd066d525157d7466d51def0bc8a764cda7176ddad6ca89b3aa65b1428fdd690
@@ -103,8 +103,17 @@ module Reactor
103
103
  end
104
104
  EOC
105
105
  end
106
+
107
+ # active model dirty tracking
108
+ attribute_methods << <<-EOC
109
+ def #{attribute}_changed?
110
+ attribute_changed?(:#{attribute})
111
+ end
112
+ EOC
106
113
  end
107
114
 
115
+
116
+
108
117
  [:contentType].each do |attribute|
109
118
  writers << attribute.to_sym
110
119
  writers << attribute.to_s.underscore.to_sym
@@ -225,6 +234,18 @@ module Reactor
225
234
  self[:channels] || []
226
235
  end
227
236
 
237
+ def body_changed?
238
+ attribute_changed?(:body)
239
+ end
240
+
241
+ def title_changed?
242
+ attribute_changed?(:title)
243
+ end
244
+
245
+ def channels_changed?
246
+ attribute_changed?(:channels)
247
+ end
248
+
228
249
  # Sets given attribute, to given value. Converts values if neccessary
229
250
  # @see [Reactor::Attributes]
230
251
  # @note options are passed to underlying xml interface, but as of now have no effect
@@ -239,8 +260,7 @@ module Reactor
239
260
  formated_value = serialize_value(key, value)
240
261
  crul_set(attr, formated_value, options)
241
262
 
242
- __send__(:attribute_will_change!, key)
243
-
263
+ __track_dirty_attribute(key)
244
264
  active_record_set(key, formated_value) if active_record_attr?(key)
245
265
  rails_connector_set(key, formated_value)
246
266
 
@@ -355,15 +375,30 @@ module Reactor
355
375
  attribute_type(attr) == :linklist
356
376
  end
357
377
 
358
- def active_record_set(field, value)
359
- if Reactor.rails4_2?
378
+ if Reactor.rails4_2?
379
+ def active_record_set(field, value)
360
380
  @attributes.write_from_user(field.to_s, value)
361
- else
381
+ end
382
+ else
383
+ def active_record_set(field, value)
362
384
  @attributes_cache.delete(field.to_s)
363
385
  @attributes[field.to_s] = value
364
386
  end
365
387
  end
366
388
 
389
+ if Reactor.rails4_2? || Reactor.rails4_1?
390
+ def __track_dirty_attribute(key)
391
+ __send__(:attribute_will_change!, key.to_s)
392
+ end
393
+ else
394
+ def __track_dirty_attribute(key)
395
+ # in rails versions <= Rails 4.0 sometimes the first option
396
+ # and sometimes the second option is used
397
+ __send__(:attribute_will_change!, key.to_s)
398
+ __send__(:attribute_will_change!, key.to_sym)
399
+ end
400
+ end
401
+
367
402
  # Lazily sets values for crul interface. May be removed in later versions
368
403
  def crul_set(field, value, options)
369
404
  @__crul_attributes ||= {}
@@ -151,33 +151,55 @@ module Reactor
151
151
 
152
152
  skip_version_creation = @attrs.empty? && links_to_remove.empty? && links_to_set.empty? && !links_modified
153
153
 
154
- # The save procedure consists of following steps:
155
- # First request (assign attributes):
156
- # a. Execute take to assign the edited content to the current user
157
- # b. Execute edit to create an edited content if there is none present
158
- # c. Set object attributes (name, permalink, etc.)
159
- # d. Set content attributes (title, body etc. + custom attributes)
160
- # e. Resolve all links in *html* attributes
161
- # Second request (overwrite linklists):
162
- # f. Remove superflous links
163
- # g. Overwrite existing links
164
- # h. Add missing links
154
+ # The save procedure consists of two multiplexed CM requests.
155
+ # Each request combines multiple operations for better performance.
165
156
  #
166
- # Second request is optional and only happens if linklists
167
- # have been changed.
157
+ # It is necessary to split the procedure into two request because
158
+ # of the linklist handling. For objects with only released content
159
+ # the edit operation copies all links (and generates new ids).
160
+ # Only the new links from the edited content can be manipulated.
161
+ # Thus it is neccessary after perform a read of links after the
162
+ # edit operation.
168
163
  #
169
- # Steps a,b,d,e,f,g,h are optional and are skipped if only
170
- # object attributes have been supplied.
164
+ # The second request may seem strange and redundant, but has very
165
+ # important reasons for being structured the way it is.
166
+ # The CM in all versions (as of this moment <= 7.0.1) contains
167
+ # multiple race conditions regarding slave workers and the CRUL
168
+ # interface.
171
169
  #
172
- # It can happen that the second request is received by
173
- # a different CM slave than the first request. If additionaly
174
- # the slave has invalid cache (for example when the cache
175
- # invalidate command has not yet been fully propagated among
176
- # slaves), then race condition can occur.
177
- # It is therefore extremely important for the second request
178
- # to be resistant against invalid cache, otherwise then
179
- # save operation aborts.
180
-
170
+ # It is possible that the two requests are processed by two different
171
+ # slave workers which have an invalid cache. Without careful
172
+ # programing it may lead to unexpected results and/or data loss.
173
+ # The reason behind it is simple: the cache invalidate requests
174
+ # are distributed asynchronously between workers.
175
+ #
176
+ # It is impossible to ensure that the two requests are processed
177
+ # by the same worker: a worker may get killed at any time, without
178
+ # warning (producing errors on keep-alive connections). Furthermore
179
+ # the workers regularly kill themselves (after X processed requests)
180
+ # to contain memory leaks.
181
+ #
182
+ # Following cases are especially important to handle correctly:
183
+ # Let Slave 1 be the worker receiving the first request and Slave 2
184
+ # be the worker receiving the second request. Let Object be the
185
+ # object on which the save operation is performed.
186
+ #
187
+ # 1. If the Object contains only released version, then Slave 2
188
+ # may be unaware of the newly created edited version by the time
189
+ # the second request is being processed. Thefore all operations
190
+ # involving indirect content references for example adding links
191
+ # (obj where ... editedContent addLinkTo) would get rejected
192
+ # by the Slave 2.
193
+ #
194
+ # 2. If the Object contains an edited version, then Slave 2 may
195
+ # be unaware of the changes perfomed on it, change of editor for
196
+ # example, and can reject valid requests. The more dramatic
197
+ # scenario involves Slave 2 persisting its invalid cached content
198
+ # which would result in a data loss.
199
+ #
200
+ # The requests have been thus crafted to deal with those problems.
201
+ # The solution is based on the precise source-code level knowledge
202
+ # of the CM internals.
181
203
  resp = MultiXmlRequest.execute do |reqs|
182
204
  reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'take') } unless skip_version_creation
183
205
  reqs.optional {|xml| SimpleCommandRequest.build(xml, @obj_id, 'edit') } unless skip_version_creation
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.20.0"
3
+ VERSION = "1.20.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails