From cf266ee00491bc0e70fbbb7dc9720a9e2f8c3708 Mon Sep 17 00:00:00 2001 From: zulan Date: Mon, 24 Sep 2018 22:54:57 +0200 Subject: Get l10n within NewUserMailHelper to ensure it always uses the new user's language. Some related tests had to be changed because they relied on internals, see also from the PHPUnit documentation: "Exercise caution when using [the at] matcher as it can lead to brittle tests which are too closely tied to specific implementation details." Signed-off-by: Zulan --- apps/provisioning_api/lib/AppInfo/Application.php | 2 +- apps/provisioning_api/lib/Controller/UsersController.php | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'apps/provisioning_api/lib') diff --git a/apps/provisioning_api/lib/AppInfo/Application.php b/apps/provisioning_api/lib/AppInfo/Application.php index b7a93d6fb13..7e9e04978fe 100644 --- a/apps/provisioning_api/lib/AppInfo/Application.php +++ b/apps/provisioning_api/lib/AppInfo/Application.php @@ -43,7 +43,7 @@ class Application extends App { return new NewUserMailHelper( $server->query(Defaults::class), $server->getURLGenerator(), - $server->getL10N('settings'), + $server->getL10NFactory(), $server->getMailer(), $server->getSecureRandom(), new TimeFactory(), diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 9aa32e1186a..27d66a83c81 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -894,16 +894,8 @@ class UsersController extends AUserData { if ($email === '' || $email === null) { throw new OCSException('Email address not available', 101); } - $username = $targetUser->getUID(); - $lang = $this->config->getUserValue($username, 'core', 'lang', 'en'); - if (!$this->l10nFactory->languageExists('settings', $lang)) { - $lang = 'en'; - } - - $l10n = $this->l10nFactory->get('settings', $lang); try { - $this->newUserMailHelper->setL10N($l10n); $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false); $this->newUserMailHelper->sendMail($targetUser, $emailTemplate); } catch(\Exception $e) { -- cgit v1.2.3