From 04e6b2fb53de95b103573d5caea994be2244eb67 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 26 Nov 2021 12:29:27 +0000 Subject: [PATCH] [ENTITY][Language] Properly handle context actor language --- src/Entity/Actor.php | 2 +- src/Entity/ActorLanguage.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index 45c96c0f83..ad914aa3cc 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -378,7 +378,7 @@ class Actor extends Entity public function getPreferredLanguageChoices(?self $context = null): array { $id = $context?->getId() ?? $this->getId(); - $key = ActorLanguage::collectionCacheKey($this); // TODO handle language context + $key = ActorLanguage::collectionCacheKey($this, $context); $langs = Cache::getHashMap( $key, fn () => F\reindex( diff --git a/src/Entity/ActorLanguage.php b/src/Entity/ActorLanguage.php index 394a9d3b29..11435cd420 100644 --- a/src/Entity/ActorLanguage.php +++ b/src/Entity/ActorLanguage.php @@ -79,9 +79,9 @@ class ActorLanguage extends Entity // @codeCoverageIgnoreEnd // }}} Autocode - public static function collectionCacheKey(LocalUser|Actor $actor) + public static function collectionCacheKey(LocalUser|Actor $actor, ?Actor $content = null) { - return 'actor-' . $actor->getId() . '-langs'; + return 'actor-' . $actor->getId() . '-langs' . (!\is_null($content) ? '-cxt-' . $content->getId() : ''); } public static function normalizeOrdering(LocalUser|Actor $actor)