Commit 6a8e3943 authored by Dries's avatar Dries

- Fixed bug #11312: menu caching to aggresively. I did not apply the proposed

  patch but moved the menu-logic to the $may_cache clause and added some checks
  to avoid SQL overhead.  I think this is the most performant solution.
parent 12eb2023
......@@ -90,11 +90,6 @@ function book_menu($may_cache) {
'callback' => 'book_admin_orphan',
'access' => user_access('administer nodes'),
'weight' => 8);
$result = db_query('SELECT n.nid, n.title FROM {node} n '. node_access_join_sql() .' INNER JOIN {book} b ON n.nid = b.nid WHERE '. node_access_where_sql() .' AND b.parent = 0 ORDER BY b.weight, n.title');
while ($book = db_fetch_object($result)) {
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
}
$items[] = array('path' => 'book', 'title' => t('books'),
'callback' => 'book_render',
'access' => user_access('access content'),
......@@ -116,6 +111,15 @@ function book_menu($may_cache) {
'type' => MENU_LOCAL_TASK, 'weight' => 2);
}
}
// We don't want to cache these menu items because they could change whenever
// a book page or outline node is edited.
if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'book') {
$result = db_query('SELECT n.nid, n.title FROM {node} n '. node_access_join_sql() .' INNER JOIN {book} b ON n.nid = b.nid WHERE '. node_access_where_sql() .' AND b.parent = 0 ORDER BY b.weight, n.title');
while ($book = db_fetch_object($result)) {
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
}
}
}
return $items;
......
......@@ -90,11 +90,6 @@ function book_menu($may_cache) {
'callback' => 'book_admin_orphan',
'access' => user_access('administer nodes'),
'weight' => 8);
$result = db_query('SELECT n.nid, n.title FROM {node} n '. node_access_join_sql() .' INNER JOIN {book} b ON n.nid = b.nid WHERE '. node_access_where_sql() .' AND b.parent = 0 ORDER BY b.weight, n.title');
while ($book = db_fetch_object($result)) {
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
}
$items[] = array('path' => 'book', 'title' => t('books'),
'callback' => 'book_render',
'access' => user_access('access content'),
......@@ -116,6 +111,15 @@ function book_menu($may_cache) {
'type' => MENU_LOCAL_TASK, 'weight' => 2);
}
}
// We don't want to cache these menu items because they could change whenever
// a book page or outline node is edited.
if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'book') {
$result = db_query('SELECT n.nid, n.title FROM {node} n '. node_access_join_sql() .' INNER JOIN {book} b ON n.nid = b.nid WHERE '. node_access_where_sql() .' AND b.parent = 0 ORDER BY b.weight, n.title');
while ($book = db_fetch_object($result)) {
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
}
}
}
return $items;
......
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