Imagine file metadata is never updated when a variant is stored again, so mediaObjects keep a changed filter's old type and size
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #422 @silverbackdan による — マージ済み
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 63/100
調査の方向性
Start by tracing ImagineEventListener::onStore() into FileInfoCacheManager::saveCache() and inspect how readStoredFilteredImageInfo uses that method. Check the existing tests for stored variants and cached metadata, then add coverage for storing the same (path, filter) again. Done means refreshed metadata reflects the stored file’s MIME type, size, and dimensions while the read path remains safe from concurrent inserts.
索引モデルが issue の本文から書いたものです。
説明
Problem
FileInfoCacheManager::saveCache() returns early when a row already exists for the (path, filter):
if ($this->resolveCache($fileInfo->path, $fileInfo->filter)) {
return;
}
ImagineEventListener::onStore() goes through saveCache(). So when a variant is stored again, its metadata row keeps the old values. Changing a filter's format, quality or size and running imagine:generate writes the new files, but _metadata.mediaObjects keeps serving the old mimeType, fileSize and dimensions.
Seen in production (template alpha.25 → alpha.27, every filter switched to format: webp)
- Every variant now has a
.webpfile and a.webpcontentUrl. Its metadata row still saysimage/png/image/jpeg, with the old file size. - Example
filemedia objects for one image: original 2124 px PNG at 3.69 MB. Thegeneralrow saysimage/pngat 1.58 MB (the stored WebP is 41 KB). Thelargerow saysimage/png, 2124 px wide, at 4.69 MB (the stored WebP is 91 KB). @cwa/nuxt'ssrcsetkeeps one candidate per width, the smallest byfileSize. Herelargeand the original are both 2124 px wide, andlargeis recorded as the bigger file. So the original goes into thesrcsetin place oflarge. Retina screens then download the 3.7 MB PNG (12.7 s on a test request) in place of the 91 KB WebP.- This hits every image whose original is no wider than
large, which is most uploads.
Suggested fix
- Store events: a stored variant should replace its metadata.
onStore()could upsert, or delete the(path, filter)row before inserting.saveCache()can stay insert-only for the read path (readStoredFilteredImageInfo), where it guards against concurrent inserts. - Existing sites: add an upgrade note to delete the stale variant rows after a filter change, so they are re-read from the stored files on the next render:
then purge the HTTP cache. Alternatively,DELETE FROM _acb_imagine_cached_file_metadata WHERE filter <> '';imagine:generatecould refresh the metadata of any variant whose row doesn't match the stored file.
- 主要言語
- PHP
- スター
- 32
- フォーク
- 8
- 平均マージ
- 40分
- マージ済み PR(30日)
- 129
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
components-web-app/api-components-bundle のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
components-web-app/api-components-bundle#333 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
components-web-app/api-components-bundle#325 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
components-web-app/api-components-bundle#259 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
components-web-app/api-components-bundle#186 ·
メンテナーはふだん 1 日以内に返信
components-web-app/api-components-bundle の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ProfessionalWiki/NeoWiki#1675 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100