Problem/Motivation
There is a db_transaction();
in MenuRouterRebuildSubscriber
The problem with that is that nothing ensures that the menu router is actually stored in the database.
Note that this does not break anything and the issue is just cleanup.
Proposed resolution
Change the definition ofplugin.manager.menu.link
incore.services.yml
to pass in@database
and store it in aconnection
. property ofMenuTreeStorage
.- Move the code block in
MenuRouterRebuildSubscriber::menuLinksRebuild()
starting with$transaction = db_transaction();
intoMenuTreeStorage::rebuild
. Keep the lock mechanism inMenuRouterRebuildSubscriber
. - Change the
db_transaction
you just moved into$this->connection->startTransaction
. - Optional and can be a followup: write a unit test for
MenuLinkManager::rebuild
. AFAIK there is no unit test currently that could be easily extended to include this method and so this part is not a novice task (but, feel free to try. You'd need to mock the plugin discovery, the module handler, the link override and the tree storage, I would borrow ideas/code fromLocalTaskManagerTest
).