[2.x] fix: gracefully handle unavailable/unconfigured adapters when rendering posts#483
Merged
Merged
Conversation
…ng posts When a file was uploaded via an adapter that is now removed or unconfigured (e.g. Imgur with no client ID set), rendering a post containing that upload would crash with a TypeError from property_exists() being passed null. - Manager::instantiate() now throws ValidationException if the factory method returns null (e.g. imgur() with no client ID configured) - FileRepository::getUrlForFile() and getThumbnailUrlForFile() catch ValidationException and return null, so post rendering degrades gracefully instead of throwing - FileRepository::cleanUp() skips files whose adapter cannot be instantiated rather than aborting mid-run - Add missing 'down' key to 2026_02_21 migration to fix MigrationKeyMissing error when running migrate:reset
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.
Summary
Manager::instantiate()would call the factory method, getnullback, then crash with aTypeErrorfromproperty_exists(null, ...)— breaking the entire forum index/discussion viewgetUrlForFile()andgetThumbnailUrlForFile()now catchValidationExceptionfrominstantiate()and returnnull, so posts degrade gracefully (falling back to the stored URL for imgur files)cleanUp()skips files whose adapter cannot be instantiated rather than abortingdownkey to the2026_02_21migration, which caused aMigrationKeyMissingerror when runningmigrate:reset