summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-10-14 21:45:37 +0000
committerDries Buytaert <dries@buytaert.net>2004-10-14 21:45:37 +0000
commit6a8e394301c557188e8cd1643b4556eb80dca7b9 (patch)
tree9848149bc81535c6ebba37edebd6e7c02b2fe4ae /modules
parent12eb20238ce54680995b58f1fef529bae4052ed0 (diff)
downloadbrdo-6a8e394301c557188e8cd1643b4556eb80dca7b9.tar.gz
brdo-6a8e394301c557188e8cd1643b4556eb80dca7b9.tar.bz2
- 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.
Diffstat (limited to 'modules')
-rw-r--r--modules/book.module14
-rw-r--r--modules/book/book.module14
2 files changed, 18 insertions, 10 deletions
diff --git a/modules/book.module b/modules/book.module
index 02323e2b1..d3348096e 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -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;
diff --git a/modules/book/book.module b/modules/book/book.module
index 02323e2b1..d3348096e 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -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;