activestorage 7.1.2 → 7.1.3.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
  SHA256:
3
- metadata.gz: bd39ea012892aff2a2c0feb20519b806a0615da59c4ad5939beef933484e19c0
4
- data.tar.gz: 9f6b7e9e6fe58b73c288655c266e90534692df771523452952bdc252f9196fff
3
+ metadata.gz: 583030fbf28ec107e4feae529ba5ba4ace30262762fa46550506090e280c27c5
4
+ data.tar.gz: 52e3e805c38cc05d863474b0a153824587e0df173896f593aa83c0f3c4cd8113
5
5
  SHA512:
6
- metadata.gz: 8f0a1f420d2766c8b8d533c001668706a1a91802beb6c1e6a96bd9cf960b8c2e031858fb1f7be2e70e39d9f5fe8443de253f7e09b71b64646d6846ee47d5180f
7
- data.tar.gz: 9e05b7594976c7113c9643b2f29546724dd4751c2a464d728de7440c5d578f1ceae6eb957dc2adc7325f857706fe44f5eebb70e2ef7085feb7076e0e44edb2e5
6
+ metadata.gz: ac9b49e9480b6e008064616fefbfd086364947143fde4661e54ea589cd77475f850c02fc46ea62354c164475d9513be0c6b3a32696e436ba075b877cb55910a8
7
+ data.tar.gz: 0c98db4330b7a88ae512574b1659e003e6f22ce8305fd02d24091419108fd224e4e7ab902b164f11aff0eb159cfffe78c2f822b752d33332e7a635968145336c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,57 @@
1
+ ## Rails 7.1.3.1 (February 21, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.1.3 (January 16, 2024) ##
7
+
8
+ * Fix N+1 query when fetching preview images for non-image assets.
9
+
10
+ *Aaron Patterson & Justin Searls*
11
+
12
+ * Fix all Active Storage database related models to respect
13
+ `ActiveRecord::Base.table_name_prefix` configuration.
14
+
15
+ *Chedli Bourguiba*
16
+
17
+ * Fix `ActiveStorage::Representations::ProxyController` not returning the proper
18
+ preview image variant for previewable files.
19
+
20
+ *Chedli Bourguiba*
21
+
22
+ * Fix `ActiveStorage::Representations::ProxyController` to proxy untracked
23
+ variants.
24
+
25
+ *Chedli Bourguiba*
26
+
27
+ * Fix direct upload forms when submit button contains nested elements.
28
+
29
+ *Marc Köhlbrugge*
30
+
31
+ * When using the `preprocessed: true` option, avoid enqueuing transform jobs
32
+ for blobs that are not representable.
33
+
34
+ *Chedli Bourguiba*
35
+
36
+ * Process preview image variant when calling `ActiveStorage::Preview#processed`.
37
+ For example, `attached_pdf.preview(:thumb).processed` will now immediately
38
+ generate the full-sized preview image and the `:thumb` variant of it.
39
+ Previously, the `:thumb` variant would not be generated until a further call
40
+ to e.g. `processed.url`.
41
+
42
+ *Chedli Bourguiba* and *Jonathan Hefner*
43
+
44
+ * Prevent `ActiveRecord::StrictLoadingViolationError` when strict loading is
45
+ enabled and the variant of an Active Storage preview has already been
46
+ processed (for example, by calling `ActiveStorage::Preview#url`).
47
+
48
+ *Jonathan Hefner*
49
+
50
+ * Fix `preprocessed: true` option for named variants of previewable files.
51
+
52
+ *Nico Wenterodt*
53
+
54
+
1
55
  ## Rails 7.1.2 (November 10, 2023) ##
2
56
 
3
57
  * No changes.
@@ -771,9 +771,9 @@ function start() {
771
771
  }
772
772
 
773
773
  function didClick(event) {
774
- const {target: target} = event;
775
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
776
- submitButtonsByForm.set(target.form, target);
774
+ const button = event.target.closest("button, input");
775
+ if (button && button.type === "submit" && button.form) {
776
+ submitButtonsByForm.set(button.form, button);
777
777
  }
778
778
  }
779
779
 
@@ -754,9 +754,9 @@
754
754
  }
755
755
  }
756
756
  function didClick(event) {
757
- const {target: target} = event;
758
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
759
- submitButtonsByForm.set(target.form, target);
757
+ const button = event.target.closest("button, input");
758
+ if (button && button.type === "submit" && button.form) {
759
+ submitButtonsByForm.set(button.form, button);
760
760
  }
761
761
  }
762
762
  function didSubmitForm(event) {
@@ -12,7 +12,7 @@ class ActiveStorage::Representations::ProxyController < ActiveStorage::Represent
12
12
 
13
13
  def show
14
14
  http_cache_forever public: true do
15
- send_blob_stream @representation.image, disposition: params[:disposition]
15
+ send_blob_stream @representation, disposition: params[:disposition]
16
16
  end
17
17
  end
18
18
  end
@@ -15,9 +15,9 @@ export function start() {
15
15
  }
16
16
 
17
17
  function didClick(event) {
18
- const { target } = event
19
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
20
- submitButtonsByForm.set(target.form, target)
18
+ const button = event.target.closest("button, input")
19
+ if (button && button.type === "submit" && button.form) {
20
+ submitButtonsByForm.set(button.form, button)
21
21
  }
22
22
  }
23
23
 
@@ -3,10 +3,10 @@
3
3
  class ActiveStorage::TransformJob < ActiveStorage::BaseJob
4
4
  queue_as { ActiveStorage.queues[:transform] }
5
5
 
6
- discard_on ActiveRecord::RecordNotFound
6
+ discard_on ActiveRecord::RecordNotFound, ActiveStorage::UnrepresentableError
7
7
  retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :polynomially_longer
8
8
 
9
9
  def perform(blob, transformations)
10
- blob.variant(transformations).processed
10
+ blob.representation(transformations).processed
11
11
  end
12
12
  end
@@ -18,8 +18,6 @@ require "active_support/core_ext/module/delegation"
18
18
  # # preloads blobs and variant records (if using `ActiveStorage.track_variants`)
19
19
  # User.first.avatars.with_all_variant_records
20
20
  class ActiveStorage::Attachment < ActiveStorage::Record
21
- self.table_name = "active_storage_attachments"
22
-
23
21
  ##
24
22
  # :method:
25
23
  #
@@ -44,7 +42,10 @@ class ActiveStorage::Attachment < ActiveStorage::Record
44
42
  # Eager load all variant records on an attachment at once.
45
43
  #
46
44
  # User.first.avatars.with_all_variant_records
47
- scope :with_all_variant_records, -> { includes(blob: { variant_records: { image_attachment: :blob } }) }
45
+ scope :with_all_variant_records, -> { includes(blob: {
46
+ variant_records: { image_attachment: :blob },
47
+ preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } }
48
+ }) }
48
49
 
49
50
  # Synchronously deletes the attachment and {purges the blob}[rdoc-ref:ActiveStorage::Blob#purge].
50
51
  def purge
@@ -99,7 +99,7 @@ module ActiveStorage::Blob::Representable
99
99
  end
100
100
 
101
101
  def preprocessed(transformations) # :nodoc:
102
- ActiveStorage::TransformJob.perform_later(self, transformations)
102
+ ActiveStorage::TransformJob.perform_later(self, transformations) if representable?
103
103
  end
104
104
 
105
105
  private
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveStorage::Blob::Servable # :nodoc:
4
+ def content_type_for_serving
5
+ forcibly_serve_as_binary? ? ActiveStorage.binary_content_type : content_type
6
+ end
7
+
8
+ def forced_disposition_for_serving
9
+ if forcibly_serve_as_binary? || !allowed_inline?
10
+ :attachment
11
+ end
12
+ end
13
+
14
+ private
15
+ def forcibly_serve_as_binary?
16
+ ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
17
+ end
18
+
19
+ def allowed_inline?
20
+ ActiveStorage.content_types_allowed_inline.include?(content_type)
21
+ end
22
+ end
@@ -20,8 +20,7 @@ class ActiveStorage::Blob < ActiveStorage::Record
20
20
  include Analyzable
21
21
  include Identifiable
22
22
  include Representable
23
-
24
- self.table_name = "active_storage_blobs"
23
+ include Servable
25
24
 
26
25
  MINIMUM_TOKEN_LENGTH = 28
27
26
 
@@ -138,7 +137,10 @@ class ActiveStorage::Blob < ActiveStorage::Record
138
137
 
139
138
  def scope_for_strict_loading # :nodoc:
140
139
  if strict_loading_by_default? && ActiveStorage.track_variants
141
- includes(variant_records: { image_attachment: :blob }, preview_image_attachment: :blob)
140
+ includes(
141
+ variant_records: { image_attachment: :blob },
142
+ preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } }
143
+ )
142
144
  else
143
145
  all
144
146
  end
@@ -226,16 +228,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
226
228
  service.headers_for_direct_upload key, filename: filename, content_type: content_type, content_length: byte_size, checksum: checksum, custom_metadata: custom_metadata
227
229
  end
228
230
 
229
- def content_type_for_serving # :nodoc:
230
- forcibly_serve_as_binary? ? ActiveStorage.binary_content_type : content_type
231
- end
232
-
233
- def forced_disposition_for_serving # :nodoc:
234
- if forcibly_serve_as_binary? || !allowed_inline?
235
- :attachment
236
- end
237
- end
238
-
239
231
 
240
232
  # Uploads the +io+ to the service on the +key+ for this blob. Blobs are intended to be immutable, so you shouldn't be
241
233
  # using this method after a file has already been uploaded to fit with a blob. If you want to create a derivative blob,
@@ -354,14 +346,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
354
346
  Marcel::MimeType.for io, name: filename.to_s, declared_type: content_type
355
347
  end
356
348
 
357
- def forcibly_serve_as_binary?
358
- ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
359
- end
360
-
361
- def allowed_inline?
362
- ActiveStorage.content_types_allowed_inline.include?(content_type)
363
- end
364
-
365
349
  def web_image?
366
350
  ActiveStorage.web_image_content_types.include?(content_type)
367
351
  end
@@ -31,15 +31,19 @@
31
31
  # These libraries are not provided by \Rails. You must install them yourself to use the built-in previewers. Before you
32
32
  # install and use third-party software, make sure you understand the licensing implications of doing so.
33
33
  class ActiveStorage::Preview
34
+ include ActiveStorage::Blob::Servable
35
+
34
36
  class UnprocessedError < StandardError; end
35
37
 
38
+ delegate :filename, :content_type, to: :variant
39
+
36
40
  attr_reader :blob, :variation
37
41
 
38
42
  def initialize(blob, variation_or_variation_key)
39
43
  @blob, @variation = blob, ActiveStorage::Variation.wrap(variation_or_variation_key)
40
44
  end
41
45
 
42
- # Processes the preview if it has not been processed yet. Returns the receiving Preview instance for convenience:
46
+ # Processes the preview if it has not been processed yet. Returns the receiving +ActiveStorage::Preview+ instance for convenience:
43
47
  #
44
48
  # blob.preview(resize_to_limit: [100, 100]).processed.url
45
49
  #
@@ -47,6 +51,7 @@ class ActiveStorage::Preview
47
51
  # image is stored with the blob, it is only generated once.
48
52
  def processed
49
53
  process unless processed?
54
+ variant.processed
50
55
  self
51
56
  end
52
57
 
@@ -53,6 +53,8 @@
53
53
  # * {ImageProcessing::Vips}[https://github.com/janko/image_processing/blob/master/doc/vips.md#methods]
54
54
  # * {ruby-vips reference}[http://www.rubydoc.info/gems/ruby-vips/Vips/Image]
55
55
  class ActiveStorage::Variant
56
+ include ActiveStorage::Blob::Servable
57
+
56
58
  attr_reader :blob, :variation
57
59
  delegate :service, to: :blob
58
60
  delegate :content_type, to: :variation
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ActiveStorage::VariantRecord < ActiveStorage::Record
4
- self.table_name = "active_storage_variant_records"
5
-
6
4
  belongs_to :blob
7
5
  has_one_attached :image
8
6
  end
@@ -5,6 +5,8 @@
5
5
  # Like an ActiveStorage::Variant, but keeps detail about the variant in the database as an
6
6
  # ActiveStorage::VariantRecord. This is only used if +ActiveStorage.track_variants+ is enabled.
7
7
  class ActiveStorage::VariantWithRecord
8
+ include ActiveStorage::Blob::Servable
9
+
8
10
  attr_reader :blob, :variation
9
11
  delegate :service, to: :blob
10
12
  delegate :content_type, to: :variation
@@ -116,7 +116,10 @@ module ActiveStorage
116
116
 
117
117
  scope :"with_attached_#{name}", -> {
118
118
  if ActiveStorage.track_variants
119
- includes("#{name}_attachment": { blob: { variant_records: { image_attachment: :blob } } })
119
+ includes("#{name}_attachment": { blob: {
120
+ variant_records: { image_attachment: :blob },
121
+ preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } }
122
+ } })
120
123
  else
121
124
  includes("#{name}_attachment": :blob)
122
125
  end
@@ -203,7 +206,10 @@ module ActiveStorage
203
206
 
204
207
  scope :"with_attached_#{name}", -> {
205
208
  if ActiveStorage.track_variants
206
- includes("#{name}_attachments": { blob: { variant_records: { image_attachment: :blob } } })
209
+ includes("#{name}_attachments": { blob: {
210
+ variant_records: { image_attachment: :blob },
211
+ preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } }
212
+ } })
207
213
  else
208
214
  includes("#{name}_attachments": :blob)
209
215
  end
@@ -26,9 +26,13 @@ module ActiveStorage
26
26
  # has_one_attached :thumbnail
27
27
  # end
28
28
  #
29
+ # <code></code>
30
+ #
29
31
  # # fixtures/active_storage/blobs.yml
30
32
  # first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
31
33
  #
34
+ # <code></code>
35
+ #
32
36
  # # fixtures/active_storage/attachments.yml
33
37
  # first_thumbnail_attachment:
34
38
  # name: thumbnail
@@ -9,8 +9,8 @@ module ActiveStorage
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
- TINY = 2
13
- PRE = nil
12
+ TINY = 3
13
+ PRE = "1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.2
4
+ version: 7.1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.2
19
+ version: 7.1.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.1.2
26
+ version: 7.1.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 7.1.2
33
+ version: 7.1.3.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 7.1.2
40
+ version: 7.1.3.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activejob
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 7.1.2
47
+ version: 7.1.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 7.1.2
54
+ version: 7.1.3.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 7.1.2
61
+ version: 7.1.3.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 7.1.2
68
+ version: 7.1.3.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: marcel
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,7 @@ files:
123
123
  - app/models/active_storage/blob/analyzable.rb
124
124
  - app/models/active_storage/blob/identifiable.rb
125
125
  - app/models/active_storage/blob/representable.rb
126
+ - app/models/active_storage/blob/servable.rb
126
127
  - app/models/active_storage/current.rb
127
128
  - app/models/active_storage/filename.rb
128
129
  - app/models/active_storage/named_variant.rb
@@ -188,10 +189,10 @@ licenses:
188
189
  - MIT
189
190
  metadata:
190
191
  bug_tracker_uri: https://github.com/rails/rails/issues
191
- changelog_uri: https://github.com/rails/rails/blob/v7.1.2/activestorage/CHANGELOG.md
192
- documentation_uri: https://api.rubyonrails.org/v7.1.2/
192
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.3.1/activestorage/CHANGELOG.md
193
+ documentation_uri: https://api.rubyonrails.org/v7.1.3.1/
193
194
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
194
- source_code_uri: https://github.com/rails/rails/tree/v7.1.2/activestorage
195
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.3.1/activestorage
195
196
  rubygems_mfa_required: 'true'
196
197
  post_install_message:
197
198
  rdoc_options: []
@@ -208,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  - !ruby/object:Gem::Version
209
210
  version: '0'
210
211
  requirements: []
211
- rubygems_version: 3.4.18
212
+ rubygems_version: 3.4.10
212
213
  signing_key:
213
214
  specification_version: 4
214
215
  summary: Local and cloud file storage framework.