From 5036b72a71793d0ee8df58aef2b4af342d83cd31 Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Thu, 27 Jan 2022 17:19:50 +0000 Subject: [PATCH] [ENTITY][Actor] Nickname is lower case transformed when generating 'actor_view_nickname', making sure that actor pages are linked accordingly --- src/Entity/Actor.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index a3f2ab6c02..dd314b393e 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -436,24 +436,21 @@ class Actor extends Entity /** * Get a URL for this actor, i.e. a user friendly URL, using the nickname + * + * @param int $type + * @return string + * @throws BugFoundException */ public function getUrl(int $type = Router::ABSOLUTE_URL): string { if ($this->getIsLocal()) { $url = null; if (Event::handle('StartGetActorUrl', [$this, $type, &$url]) === Event::next) { - switch ($this->type) { - case self::PERSON: - case self::ORGANISATION: - case self::BOT: - $url = Router::url('actor_view_nickname', ['nickname' => $this->getNickname()], $type); - break; - case self::GROUP: - $url = Router::url('group_actor_view_nickname', ['nickname' => $this->getNickname()], $type); - break; - default: - throw new BugFoundException('Actor type added but `Actor::getUrl` was not updated'); - } + $url = match ($this->type) { + self::PERSON, self::ORGANISATION, self::BOT => Router::url('actor_view_nickname', ['nickname' => mb_strtolower($this->getNickname())], $type), + self::GROUP => Router::url('group_actor_view_nickname', ['nickname' => $this->getNickname()], $type), + default => throw new BugFoundException('Actor type added but `Actor::getUrl` was not updated'), + }; Event::handle('EndGetActorUrl', [$this, $type, &$url]); } } else {