Skip to content

Commit f1d370d

Browse files
authored
Ensure a language is set in all views (#41021)
1 parent 8c810a1 commit f1d370d

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

administrator/components/com_users/src/Helper/Mfa.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public static function getConfigurationInterface(User $user): ?string
114114
$view->returnURL = base64_encode(Uri::getInstance()->toString());
115115
$view->user = $user;
116116
$view->set('forHMVC', true);
117+
$view->setLanguage($app->getLanguage());
117118

118119
@ob_start();
119120

components/com_config/src/View/Templates/HtmlView.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Joomla\CMS\MVC\Factory\MVCFactory;
1616
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1717
use Joomla\Component\Config\Administrator\Controller\RequestController;
18+
use Joomla\Component\Templates\Administrator\View\Style\JsonView;
1819

1920
// phpcs:disable PSR1.Files.SideEffects
2021
\defined('_JEXEC') or die;
@@ -91,8 +92,10 @@ public function display($tpl = null)
9192
/** @var MVCFactory $factory */
9293
$factory = $app->bootComponent('com_templates')->getMVCFactory();
9394

95+
/** @var JsonView $view */
9496
$view = $factory->createView('Style', 'Administrator', 'Json');
9597
$view->setModel($factory->createModel('Style', 'Administrator'), true);
98+
$view->setLanguage($app->getLanguage());
9699

97100
$view->document = $this->getDocument();
98101

libraries/src/MVC/View/HtmlView.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Joomla\CMS\Uri\Uri;
1818
use Joomla\CMS\User\CurrentUserInterface;
1919
use Joomla\CMS\User\CurrentUserTrait;
20+
use UnexpectedValueException;
2021

2122
// phpcs:disable PSR1.Files.SideEffects
2223
\defined('JPATH_PLATFORM') or die;
@@ -368,8 +369,13 @@ public function loadTemplate($tpl = null)
368369
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $file);
369370
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $tpl) : $tpl;
370371

371-
// Load the language file for the template
372-
$lang = $this->getLanguage();
372+
try {
373+
// Load the language file for the template
374+
$lang = $this->getLanguage();
375+
} catch (UnexpectedValueException $e) {
376+
$lang = Factory::getApplication()->getLanguage();
377+
}
378+
373379
$lang->load('tpl_' . $template->template, JPATH_BASE)
374380
|| $lang->load('tpl_' . $template->parent, JPATH_THEMES . '/' . $template->parent)
375381
|| $lang->load('tpl_' . $template->template, JPATH_THEMES . '/' . $template->template);

tests/System/integration/site/components/com_users/Reset.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ describe('Test in frontend that the users reset view', () => {
5454
cy.wrap(mails).should('have.lengthOf', 0);
5555
});
5656
});
57+
58+
it('can show the profile page when logged in', () => {
59+
cy.doFrontendLogin();
60+
cy.visit('/index.php?option=com_users&view=reset');
61+
cy.get('#users-profile-core').should('contain.text', 'Profile');
62+
});
5763
});

0 commit comments

Comments
 (0)