fix: extensions not being able to use the renderer without context (#3382)

This commit is contained in:
Ian Morland 2022-04-07 17:53:37 +01:00 committed by GitHub
parent c944fd0029
commit b0fa795cc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ class FormatUserMentions
public function __invoke(Renderer $renderer, $context, string $xml)
{
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
$user = (isset($context->getRelations()['mentionsUsers']) || $context instanceof Post)
$user = (($context && isset($context->getRelations()['mentionsUsers'])) || $context instanceof Post)
? $context->mentionsUsers->find($attributes['id'])
: User::find($attributes['id']);

View File

@ -51,7 +51,7 @@ class UnparseUserMentions
protected function updateUserMentionTags($context, string $xml): string
{
return Utils::replaceAttributes($xml, 'USERMENTION', function ($attributes) use ($context) {
$user = (isset($context->getRelations()['mentionsUsers']) || $context instanceof Post)
$user = (($context && isset($context->getRelations()['mentionsUsers'])) || $context instanceof Post)
? $context->mentionsUsers->find($attributes['id'])
: User::find($attributes['id']);