Imagine file metadata is never updated when a variant is stored again, so mediaObjects keep a changed filter's old type and size
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
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
.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.
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di components-web-app/api-components-bundle
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
components-web-app/api-components-bundle#333 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
components-web-app/api-components-bundle#325 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
components-web-app/api-components-bundle#259 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
components-web-app/api-components-bundle#186 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di components-web-app/api-components-bundle
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Automattic/blocks-engine#2803 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hestiacp/hestiacp#5798 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
I maintainer di solito rispondono entro 1 giorno
-
Sidebar highlights two items when plugin routes share a prefix (/plugin/foo and /plugin/foo-bar)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
getgrav/grav-plugin-admin2#195 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno