fix(sources): keep getObjectContents body when metadata fails - #79
Open
Ibochkarev wants to merge 1 commit into
Open
fix(sources): keep getObjectContents body when metadata fails#79Ibochkarev wants to merge 1 commit into
Ibochkarev wants to merge 1 commit into
Conversation
S3 adapters can throw UnableToRetrieveMetadata for mime/size/mtime after a successful read. Returning [] discarded the payload (modxcms#16497). Soft-fail metadata instead, and cover the regression with a mock filesystem test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что сделано
modMediaSource::getObjectContents()по-прежнему сначала читает файл. ЕслиfileSize,lastModifiedилиmimeTypeвыбрасываютUnableToRetrieveMetadata, он сохраняет body и заполняет мягкие дефолты (size/last_modifiedfalse,mimeapplication/octet-stream) вместо возврата пустого массива.Более ранний S3-only override нормализации пути убран: Flysystem уже нормализует разделители, и это изменение не адресовало пустой контент.
Зачем нужно
На S3 вызовы метаданных часто падают, даже когда
read()успешен (тот же класс проблем, что опустошал листинги контейнера после миграции Flysystem v2). Вызывающие тогда видели$result['content']отсутствующим, потому что весь ответ был[](modxcms#16497).Как проверить
phpunit --filter MediaSourceGetObjectContentsTest$source->getObjectContents($filePath)для существующего объекта и подтвердите, чтоcontentнепустой, даже когда Content-Type метаданные отсутствуют.Связанные
Refs modxcms#16497
Оригинал: modxcms#16847