Rendering avatars throws a RuntimeError
martinspain opened this issue · comments
martinspain commented
Describe the bug
When rendering comments on an entry, if a commenter has a user photo set, a RuntimeError will be thrown:
Twig Runtime Error – [Twig\Error\RuntimeError]
Calling unknown method: craft\models\Volume::fileExists()
This is caused by the {% set avatar = craft.comments.getAvatar() %}
line in templates/_special/_includes/form.html
, which calls CommentsHelper::getAvatar()
. A private _assetExists()
method then tries to check if the asset exists:
$asset->getVolume()->fileExists($asset->getPath());
It's calling the fileExists()
method on the asset's Volume model instead of the FsInterface of the Volume, which is what's causing the error. I believe the line should be:
$asset->getVolume()->getFs()->fileExists($asset->getPath());
Steps to reproduce
- Render a set of comments against an entry where at least one of the commenters has a user photo set on their User account.
- Observe the error.
Craft CMS version
4.2.0
Plugin version
2.0.0
Multi-site?
No
Additional context
No response
Josh Crawford commented
Fixed in 2.0.1