Skip to content

Commit

Permalink
Regression at createUri from #19099
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Narloch committed Jan 20, 2018
1 parent 5994eb1 commit 3655a6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 1 addition & 3 deletions components/com_content/views/archive/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</h1>
</div>
<?php endif; ?>
<form id="adminForm" action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-inline">
<form id="adminForm" action="<?php echo JRoute::_('index.php?option=com_content&view=archive'); ?>" method="post" class="form-inline">
<fieldset class="filters">
<div class="filter-search">
<?php if ($this->params->get('filter_field') !== 'hide') : ?>
Expand All @@ -34,8 +34,6 @@
<?php echo $this->form->limitField; ?>

<button type="submit" class="btn btn-primary" style="vertical-align: top;"><?php echo JText::_('JGLOBAL_FILTER_BUTTON'); ?></button>
<input type="hidden" name="view" value="archive" />
<input type="hidden" name="option" value="com_content" />
<input type="hidden" name="limitstart" value="0" />
</div>
<br />
Expand Down
7 changes: 7 additions & 0 deletions libraries/src/Router/SiteRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,13 @@ protected function createUri($url)
{
$uri->setVar('option', $option);
}

$itemid = $this->getVar('Itemid');

if ($itemid)
{
$uri->setVar('Itemid', $itemid);
}
}
}
else
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/suites/libraries/cms/router/JRouterSiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,18 @@ public function casesCreateUri()
'preset' => array('option' => 'com_test'),
'expected' => 'index.php?var1=value1&option=com_test'
),
// Check if a URL with no Itemid and no option, but globally set Itemid is added the Itemid
array(
'url' => 'index.php?var1=value1',
'preset' => array('Itemid' => '42'),
'expected' => 'index.php?var1=value1&Itemid=42'
),
// Check if a URL with no Itemid and no option, but with an option and a global Itemid available, which fits the option of the menu item gets the Itemid and option appended
array(
'url' => 'index.php?var1=value1',
'preset' => array('Itemid' => '42', 'option' => 'com_test'),
'expected' => 'index.php?var1=value1&option=com_test&Itemid=42'
),
);
}

Expand Down

0 comments on commit 3655a6e

Please sign in to comment.