Commit 8096a6c1 authored by alexpott's avatar alexpott

Issue #2398805 by dawehner, chx: MenuTreeStorage::loadTreeData loses conditions

parent 5662f41a
......@@ -808,7 +808,7 @@ public function loadTreeData($menu_name, MenuTreeParameters $parameters) {
// Build the cache ID; sort 'expanded' and 'conditions' to prevent duplicate
// cache items.
sort($parameters->expandedParents);
sort($parameters->conditions);
asort($parameters->conditions);
$tree_cid = "tree-data:$menu_name:" . serialize($parameters);
$cache = $this->menuCacheBackend->get($tree_cid);
if ($cache && isset($cache->data)) {
......
......@@ -267,6 +267,35 @@ public function testLoadTree() {
$this->assertTrue($tree['test4']['in_active_trail']);
$this->assertEqual(count($tree['test4']['subtree']['test5']['subtree']), 0);
$this->assertTrue($tree['test4']['subtree']['test5']['in_active_trail']);
// Add some conditions to ensure that conditions work as expected.
$parameters = new MenuTreeParameters();
$parameters->addCondition('parent', 'test1');
$data = $this->treeStorage->loadTreeData('tools', $parameters);
$this->assertEqual(count($data['tree']), 1);
$this->assertEqual($data['tree']['test2']['definition']['id'], 'test2');
$this->assertEqual($data['tree']['test2']['subtree'], []);
// Test for only enabled links.
$link = $this->treeStorage->load('test3');
$link['enabled'] = FALSE;
$this->treeStorage->save($link);
$link = $this->treeStorage->load('test4');
$link['enabled'] = FALSE;
$this->treeStorage->save($link);
$link = $this->treeStorage->load('test5');
$link['enabled'] = FALSE;
$this->treeStorage->save($link);
$parameters = new MenuTreeParameters();
$parameters->onlyEnabledLinks();
$data = $this->treeStorage->loadTreeData('tools', $parameters);
$this->assertEqual(count($data['tree']), 1);
$this->assertEqual($data['tree']['test1']['definition']['id'], 'test1');
$this->assertEqual(count($data['tree']['test1']['subtree']), 1);
$this->assertEqual($data['tree']['test1']['subtree']['test2']['definition']['id'], 'test2');
$this->assertEqual($data['tree']['test1']['subtree']['test2']['subtree'], []);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment