Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize menu_rebuild() #3659

Conversation

hosef
Copy link
Contributor

@hosef hosef commented Jul 9, 2021

Reducing the number of database queries used when a menu link is saved or when the menus are rebuilt.

Fixes backdrop/backdrop-issues#5389

@hosef hosef requested review from indigoxela and removed request for indigoxela December 3, 2021 15:25
@indigoxela
Copy link
Member

@hosef which issue does this PR refer to?

@hosef
Copy link
Contributor Author

hosef commented Dec 9, 2021

@indigoxela there isn't actually an issue. I initially wasn't even sure this would work. I just made the PR to see how the test bot would handle it.

@docwilmot
Copy link
Contributor

This PR says it optimizes menu_rebuild() but the issue says menu_navigation_links_rebuild().

@hosef
Copy link
Contributor Author

hosef commented Dec 16, 2021

@docwilmot
When I initially created the PR, I was trying to make menu_rebuild() faster, but I didn't create an issue because I wasn't sure it would work or if anything would come of it. After finally getting it working, it turned out that most of my changes where in menu_navigation_links_rebuild(), so that is the function name I put in the issue title.

@jenlampton
Copy link
Member

@hosef great work, I'm impressed you were able to remove so many database queries (and surprised there were so many to remove!)

I have one question, why were these tests removed?

   // Start over, forcefully delete child-1 from the database, simulating a
    // database crash. Check that the children of child-1 have been reassigned
    // to the parent, going up on the old path hierarchy stored in each of the
    // links.

@hosef
Copy link
Contributor Author

hosef commented Dec 23, 2021

@jenlampton Those tests were checking the behavior of the menu re-parenting when a different page uses a manual database query to remove a menu link in the middle of your page load.
I don't think this should be supported behavior because we have provided menu_delete as a supported method of removing a menu link. We also don't support that in any other context, such as checking that a node wasn't deleted in the middle of generating a view.

@jenlampton
Copy link
Member

@hosef Does this change cause those tests to fail?

If not, I'd prefer that we remove those tests in a separate issue where we can discuss why it was supported in the first place, just in case there's something else we're missing. Including that decision in an optimization issue might be setting us up for unforeseen consequences and it makes me nervous :)

@hosef
Copy link
Contributor Author

hosef commented Dec 24, 2021

Those tests can't pass with the new code because they bypass the built in menu API functions, so they don't update the static cache used internally in menu_rebuild().

@jenlampton
Copy link
Member

jenlampton commented Dec 24, 2021 via email

core/includes/menu.inc Outdated Show resolved Hide resolved
@dragonbot
Copy link
Collaborator

Tugboat has finished building a preview for this pull request!

Website: https://pr3659-uaathajauinc6qcrjnh2xjmjxi9vvsnu.tugboat.qa/
Username: admin
Password: 3ed79224f533

@quicksketch quicksketch merged commit 8430f92 into backdrop:1.x Jan 2, 2022
@quicksketch
Copy link
Member

I've merged this into 1.x for inclusion in 1.21.0. Great work @hosef!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants