[SECURITY][Register] New users should have their current browser language set as first language preference
This commit is contained in:
parent
3f8fab0021
commit
0d1ab2c9cf
|
@ -29,6 +29,7 @@ use App\Util\Exception\NotFoundException;
|
||||||
use App\Util\Exception\ServerException;
|
use App\Util\Exception\ServerException;
|
||||||
use App\Util\Form\FormFields;
|
use App\Util\Form\FormFields;
|
||||||
use App\Util\Nickname;
|
use App\Util\Nickname;
|
||||||
|
use Component\Language\Entity\ActorLanguage;
|
||||||
use Component\Subscription\Entity\Subscription;
|
use Component\Subscription\Entity\Subscription;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
|
@ -166,6 +167,11 @@ class Security extends Controller
|
||||||
// Self subscription for the Home feed and alike
|
// Self subscription for the Home feed and alike
|
||||||
DB::persist(Subscription::create(['subscriber_id' => $id, 'subscribed_id' => $id]));
|
DB::persist(Subscription::create(['subscriber_id' => $id, 'subscribed_id' => $id]));
|
||||||
Feed::createDefaultFeeds($id, $user);
|
Feed::createDefaultFeeds($id, $user);
|
||||||
|
DB::persist(ActorLanguage::create([
|
||||||
|
'actor_id' => $id,
|
||||||
|
'language_id' => Common::currentLanguage()->getId(),
|
||||||
|
'ordering' => 1,
|
||||||
|
]));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,7 @@ abstract class Cache
|
||||||
/**
|
/**
|
||||||
* Retrieve a list from the cache, with a different implementation
|
* Retrieve a list from the cache, with a different implementation
|
||||||
* for redis and others, trimming to $max_count if given
|
* for redis and others, trimming to $max_count if given
|
||||||
|
* TODO(hugo): $calculate = [] is the same as false miss
|
||||||
*
|
*
|
||||||
* @param callable(?CacheItem $item, bool &$save): (string|object|array<int,mixed>) $calculate
|
* @param callable(?CacheItem $item, bool &$save): (string|object|array<int,mixed>) $calculate
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -323,6 +323,6 @@ abstract class Common
|
||||||
|
|
||||||
public static function currentLanguage(): Language
|
public static function currentLanguage(): Language
|
||||||
{
|
{
|
||||||
return self::actor()?->getTopLanguage() ?? Language::getByLocale(!\is_null(self::$request->headers->get('accept-language')) ? I18n::clientPreferredLanguage(self::$request->headers->get('accept-language')) : self::$request->getDefaultLocale());
|
return self::actor()?->getTopLanguage() ?? Language::getByLocale(!\is_null(self::$request->headers->get('accept-language')) ? I18n::clientPreferredLanguage(self::$request->headers->get('accept-language')) : self::config('site', 'language'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user