Check what happens on D7:

- main forum page is built up. advanced_forum_forum_load(0) does complicated SQL queries for every forum to retrieve "last post" results. Caches them.

- later on, forum_menu_local_tasks_alter() is fired. Which calls forum_forum_load(0), which does the same SQL queries again, to retrieve the same results.

Now check the patch for how easy it is to make sure the second iteration retrieves cached results instead of firing SQL queries.

CommentFileSizeAuthor
advanced_forum-change-static-id.patch1.96 KBroderik

Comments

troky’s picture

This problem bothers me for a long time but I couldn't find the good way to avoid calling forum_forum_load() from forum_menu_local_tasks_alter().
This patch looks good. I'll try it later today.

roderik’s picture

Quick patch turnaround, cool :)

Messing with other functions' drupal_static() cache isn't extensively documented, but it's allowed.
(The rest of the patch, including the ' ? : ' conditional, is just fluff.)

troky’s picture

Status: Needs review » Fixed

Committed. Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.