Skip to content

Commit

Permalink
Fix no menu item pages giving wrong links
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Sep 12, 2016
1 parent fc41a23 commit 9565d68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libraries/cms/component/router/rules/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public function __construct(JComponentRouterView $router)
*/
public function preprocess(&$query)
{
if (isset($query['Itemid']) && $this->router->menu->getActive() && $query['Itemid'] != $this->router->menu->getActive()->id)
/**
* If the active item id is not the same as the supplied item id or we have a supplied item id and no active
* menu item then we just use the supplied menu item and continue
*/
if (isset($query['Itemid'])
&& (($this->router->menu->getActive() && $query['Itemid'] != $this->router->menu->getActive()->id)
|| ($this->router->menu->getActive() === null)))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public function testPreprocessLanguage()
$this->object->preprocess($query);
$this->assertEquals(array('Itemid' => '47'), $query);

// If we inject a item id and we have no active menu item we should get the injected item id
$query = array('Itemid' => '50');
$this->object->preprocess($query);
$this->assertEquals(array('Itemid' => '50'), $query);

// Test if the correct default item is used based on the language
$query = array('lang' => 'en-GB');
$this->object->preprocess($query);
Expand Down

0 comments on commit 9565d68

Please sign in to comment.