Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#421 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #422 di @silverbackdan — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
63/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, symfony
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
PHP
Stelle
32
Fork
8
Merge medio
40m
PR unite (30g)
129

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di components-web-app/api-components-bundle

Tutte le issue di components-web-app/api-components-bundle

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.