Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Imagine file metadata is never updated when a variant is stored again, so mediaObjects keep a changed filter's old type and size

クローズ
#421 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #422 @silverbackdan による — マージ済み

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
63/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, symfony
領域
backend, databases

調査の方向性

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 .webp file and a .webp contentUrl. Its metadata row still says image/png / image/jpeg, with the old file size.
  • Example file media objects for one image: original 2124 px PNG at 3.69 MB. The general row says image/png at 1.58 MB (the stored WebP is 41 KB). The large row says image/png, 2124 px wide, at 4.69 MB (the stored WebP is 91 KB).
  • @cwa/nuxt's srcset keeps one candidate per width, the smallest by fileSize. Here large and the original are both 2124 px wide, and large is recorded as the bigger file. So the original goes into the srcset in place of large. 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:
    DELETE FROM _acb_imagine_cached_file_metadata WHERE filter <> '';
    
    then purge the HTTP cache. Alternatively, imagine:generate could refresh the metadata of any variant whose row doesn't match the stored file.
主要言語
PHP
スター
32
フォーク
8
平均マージ
40分
マージ済み PR(30日)
129

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

components-web-app/api-components-bundle のほかの issue

components-web-app/api-components-bundle の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。