Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions components/com_contact/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ public function getContactId($segment, $query)
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__contact_details'))
->where(
[
$this->db->quoteName('alias') . ' = :alias',
$this->db->quoteName('catid') . ' = :catid',
]
)
->bind(':alias', $segment)
->bind(':catid', $query['id'], ParameterType::INTEGER);
->where($this->db->quoteName('alias') . ' = :alias')
->bind(':alias', $segment);

if (isset($query['id']) && $query['id']) {
$dbquery->where($this->db->quoteName('catid') . ' = :catid')
->bind(':catid', $query['id'], ParameterType::INTEGER);
}

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
Expand Down
16 changes: 8 additions & 8 deletions components/com_content/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ public function getArticleId($segment, $query)
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__content'))
->where(
[
$this->db->quoteName('alias') . ' = :alias',
$this->db->quoteName('catid') . ' = :catid',
]
)
->bind(':alias', $segment)
->bind(':catid', $query['id'], ParameterType::INTEGER);
->where($this->db->quoteName('alias') . ' = :segment')
->bind(':segment', $segment);

if (isset($query['id']) && $query['id']) {
$dbquery->where($this->db->quoteName('catid') . ' = :id')
->bind(':id', $query['id'], ParameterType::INTEGER);
}

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
Expand Down
16 changes: 8 additions & 8 deletions components/com_newsfeeds/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ public function getNewsfeedId($segment, $query)
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__newsfeeds'))
->where(
[
$this->db->quoteName('alias') . ' = :segment',
$this->db->quoteName('catid') . ' = :id',
]
)
->bind(':segment', $segment)
->bind(':id', $query['id'], ParameterType::INTEGER);
->where($this->db->quoteName('alias') . ' = :segment')
->bind(':segment', $segment);

if (isset($query['id']) && $query['id']) {
$dbquery->where($this->db->quoteName('catid') . ' = :id')
->bind(':id', $query['id'], ParameterType::INTEGER);
}

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
Expand Down
28 changes: 23 additions & 5 deletions components/com_tags/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Joomla\CMS\Component\Router\RouterBase;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Database\DatabaseInterface;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
Expand Down Expand Up @@ -47,6 +49,16 @@ class Router extends RouterBase
*/
protected $lookup = [];

/**
* System - SEF Plugin parameters
*
* @var Registry
* @since __DEPLOY_VERSION__
* @deprecated __DEPLOY_VERSION__ will be removed in 6.0
* without replacement
*/
private $sefparams;

/**
* Tags Component router constructor
*
Expand All @@ -63,6 +75,9 @@ public function __construct(SiteApplication $app, AbstractMenu $menu, ?CategoryF

parent::__construct($app, $menu);

$sefPlugin = PluginHelper::getPlugin('system', 'sef');
$this->sefparams = new Registry($sefPlugin->params);

$this->buildLookup();
}

Expand Down Expand Up @@ -141,12 +156,15 @@ public function preprocess($query)
}
}

// If not found, return language specific home link
if (!isset($query['Itemid'])) {
$default = $this->menu->getDefault($lang);
// TODO: Remove this whole block in 6.0 as it is a bug
if (!$this->sefparams->get('strictrouting', 0)) {
// If not found, return language specific home link
if (!isset($query['Itemid'])) {
$default = $this->menu->getDefault($lang);

if (!empty($default->id)) {
$query['Itemid'] = $default->id;
if (!empty($default->id)) {
$query['Itemid'] = $default->id;
}
}
}

Expand Down
43 changes: 30 additions & 13 deletions libraries/src/Component/Router/Rules/MenuRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Component\Router\RouterView;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -40,6 +42,16 @@ class MenuRules implements RulesInterface
*/
protected $lookup = [];

/**
* System - SEF Plugin parameters
*
* @var Registry
* @since __DEPLOY_VERSION__
* @deprecated __DEPLOY_VERSION__ will be removed in 6.0
* without replacement
*/
private $sefparams;

/**
* Class constructor.
*
Expand All @@ -49,7 +61,9 @@ class MenuRules implements RulesInterface
*/
public function __construct(RouterView $router)
{
$this->router = $router;
$this->router = $router;
$sefPlugin = PluginHelper::getPlugin('system', 'sef');
$this->sefparams = new Registry($sefPlugin->params);

$this->buildLookup();
}
Expand Down Expand Up @@ -152,21 +166,24 @@ public function preprocess(&$query)
}
}

// Check if the active menuitem matches the requested language
if (
$active && $active->component === 'com_' . $this->router->getName()
&& ($language === '*' || \in_array($active->language, ['*', $language]) || !Multilanguage::isEnabled())
) {
$query['Itemid'] = $active->id;
// TODO: Remove this whole block in 6.0 as it is a bug
if (!$this->sefparams->get('strictrouting', 0)) {
// Check if the active menuitem matches the requested language
if (
$active && $active->component === 'com_' . $this->router->getName()
&& ($language === '*' || \in_array($active->language, ['*', $language]) || !Multilanguage::isEnabled())
) {
$query['Itemid'] = $active->id;

return;
}
return;
}

// If not found, return language specific home link
$default = $this->router->menu->getDefault($language);
// If not found, return language specific home link
$default = $this->router->menu->getDefault($language);

if (!empty($default->id)) {
$query['Itemid'] = $default->id;
if (!empty($default->id)) {
$query['Itemid'] = $default->id;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Test in frontend that the contact details view', () => {
it('can display a form', () => {
cy.db_getUserId().then((id) => cy.db_createContact({ name: 'contact 1', user_id: id }))
.then((contact) => {
cy.visit(`/index.php?option=com_contact&view=contact&id='${contact.id}'`);
cy.visit(`/index.php?option=com_contact&view=contact&id=${contact.id}`);

cy.contains('Contact Form');
cy.get('.m-0').should('exist');
Expand All @@ -17,7 +17,7 @@ describe('Test in frontend that the contact details view', () => {
.then(() => cy.db_getUserId())
.then((userId) => cy.db_createContact({ name: 'automated test contact 1', user_id: userId }))
.then((contact) => {
cy.visit(`/index.php?option=com_contact&view=contact&id='${contact.id}'`);
cy.visit(`/index.php?option=com_contact&view=contact&id=${contact.id}`);

cy.contains('automated test_field group').should('exist');
cy.contains('test field').should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Test in frontend that the users profile view edit layout', () => {
cy.get('.controls > .btn-primary').should('be.visible').click({ force: true });

cy.get('#system-message-container').contains('Profile saved.');
cy.get('.profile .btn-primary').should('be.visible').click({ force: true });
cy.get('#jform_name').should('have.value', 'automated test user edited');
cy.get('#jform_email1').should('have.value', 'testedited@example.com');
});
Expand Down
23 changes: 0 additions & 23 deletions tests/System/integration/site/components/com_users/Remind.cy.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
describe('Test in frontend that the users remind view', () => {
beforeEach(() => cy.task('clearEmails'));

it('can send a reminder email for a test user in a menu item', () => {
cy.db_createUser({ name: 'test user', email: 'test@example.com' })
.then(() => cy.db_createMenuItem({
title: 'Automated test reminder', alias: 'test-reminder', path: 'test-reminder', link: 'index.php?option=com_users&view=remind',
}))
.then(() => {
cy.visit('/');
cy.get('a:contains(Automated test reminder)').click();
cy.get('#jform_email').type('test@example.com');
cy.get('.controls > .btn').click();

cy.task('getMails').then((mails) => {
cy.get('#system-message-container').should('contain.text', 'If the email address you entered is registered on this site you will shortly receive an email with a reminder.');

expect(mails.length).to.equal(1);
cy.wrap(mails[0].body).should('have.string', 'A username reminder has been requested');
cy.wrap(mails[0].body).should('have.string', '/test-reminder');
cy.wrap(mails[0].sender).should('equal', Cypress.env('email'));
cy.wrap(mails[0].receivers).should('have.property', 'test@example.com');
});
});
});

it('can send a reminder email for a test user without a menu item', () => {
cy.db_createUser({ name: 'test user', email: 'test@example.com' })
.then(() => {
Expand Down