Account created on 12 July 2018, almost 6 years ago
#

Recent comments

We've just run into a similar issue: menu items and their children being attached to the entirely wrong parent seemingly for no reason, even when all items were active

It ultimately stems from the list of links returned from DB query in MenuTreeStorage::loadLinks() not being ordered properly, despite the function correctly setting the SQL orders (p1 ASC, p2 ASC, etc.) before querying and the data in the DB being correct. It seems to make no sense. It's mostly ordering it correctly, but a few odd items are being moved out of order somehow

    for ($i = 1; $i <= $this->maxDepth(); $i++) {
      $query->orderBy('p' . $i, 'ASC');
    }
    ...
    $links = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC);
    // links are already out of order

Perhaps there's a bug in the SQL fetch code that leads to the row order being wrecked when converted to an associative array, or perhaps there's some custom hook that runs after queries

This code triggers the issue:

$parameters = new MenuTreeParameters();
$parameters->onlyEnabledLinks();

This doesn't:

$parameters = new MenuTreeParameters();

It seems this also doesn't tho πŸ™ƒ:

$parameters = new MenuTreeParameters();
$parameters->onlyEnabledLinks();
$parameters->addCondition('expanded', 1);
$parameters->setActiveTrail([...]);
$parameters->setMaxDepth(3);

We're working around the issue by not using onlyEnabledLinks() and instead manually filtering out disabled links after loading the full tree

Production build 0.69.0 2024