? boost-611700.patch Index: boost.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v retrieving revision 1.1.2.1.2.3.2.101 diff -u -p -r1.1.2.1.2.3.2.101 boost.admin.inc --- boost.admin.inc 1 Nov 2009 04:55:41 -0000 1.1.2.1.2.3.2.101 +++ boost.admin.inc 1 Nov 2009 10:15:08 -0000 @@ -413,6 +413,17 @@ function boost_admin_boost_performance_p '#default_value' => BOOST_FLUSH_NODE_TERMS, '#description' => t('Works with view\'s taxonomy/term/% path as well as core.'), ); + $form['advanced']['boost_flush_menu_items'] = array( + '#type' => 'radios', + '#title' => t('Clear all cached pages in a menu on an insert/update/delete opperation'), + '#default_value' => BOOST_FLUSH_MENU_ITEMS, + '#description' => t('This can flush a lot of pages depending on your menu structure.'), + '#options' => array( + 0 => t('Disabled'), + 1 => t('Only Flush Menu Parrents, Siblings & Children'), + 2 => t('Flushes Entire Menu Tree'), + ), + ); $form['advanced']['boost_flush_views'] = array( '#type' => 'checkbox', '#title' => t('Clear all cached views pages associated with a node on update/delete'), @@ -1022,7 +1033,7 @@ function boost_admin_generate_htaccess($ $string .= " # Caching for anonymous users\n"; $string .= " # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request\n"; $string .= " RewriteCond %{REQUEST_METHOD} !^GET$ [OR]\n"; - $string .= " RewriteCond %{REQUEST_URI} (^$drupal_subdir(admin|$cache_dir|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]\n"; + $string .= " RewriteCond %{REQUEST_URI} (^$drupal_subdir(admin|logout|$cache_dir|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]\n"; $string .= " RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]\n"; $string .= BOOST_LOOPBACK_BYPASS ? " RewriteCond %{REMOTE_ADDR} ^$server_ip$ [OR]\n" : ''; $string .= " RewriteCond %{HTTPS} on\n"; Index: boost.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v retrieving revision 1.3.2.2.2.5.2.219 diff -u -p -r1.3.2.2.2.5.2.219 boost.module --- boost.module 1 Nov 2009 04:56:48 -0000 1.3.2.2.2.5.2.219 +++ boost.module 1 Nov 2009 10:15:09 -0000 @@ -64,6 +64,7 @@ define('BOOST_ASYNCHRONOUS_OUTPUT', var define('BOOST_FLUSH_DIR', variable_get('boost_flush_dir', FALSE)); define('BOOST_FLUSH_CCK_REFERENCES', variable_get('boost_flush_cck_references', TRUE)); define('BOOST_FLUSH_NODE_TERMS', variable_get('boost_flush_node_terms', TRUE)); +define('BOOST_FLUSH_MENU_ITEMS', variable_get('boost_flush_menu_items', 0)); define('BOOST_FLUSH_VIEWS', variable_get('boost_flush_views', TRUE)); define('BOOST_FLUSH_VIEWS_INSERT', variable_get('boost_flush_views_insert', TRUE)); define('BOOST_CLEAR_CACHE_OFFLINE', variable_get('boost_clear_cache_offline', FALSE)); @@ -521,7 +522,9 @@ function boost_votingapi_delete($votes) } /** - * Expires a node from the cache. + * Expires a node from the cache; including related pages. + * + * Expires front page if promoted, taxonomy terms, * * @param $node * node object @@ -532,6 +535,7 @@ function boost_expire_node($node, $nid = $data = array(); $paths = array(); + // Check node object if (empty($node->nid)) { if ($nid) { $node->nid = $nid; @@ -541,10 +545,7 @@ function boost_expire_node($node, $nid = } } - // Expire all relevant node pages from the static page cache to prevent serving stale content: - if ($node->promote == 1) { - $paths[] = ''; - } + // Expire this node if (BOOST_NO_DATABASE) { $paths[] = 'node/' . $node->nid; } @@ -552,7 +553,12 @@ function boost_expire_node($node, $nid = $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $node->nid); } - // Get terms and flush their page + // If promoted to front page, expire front page + if ($node->promote == 1) { + $paths[] = ''; + } + + // Get taxonomy terms and flush if (module_exists('taxonomy') && BOOST_FLUSH_NODE_TERMS) { $tids = boost_taxonomy_node_get_tids($node->nid); $filenames = array(); @@ -566,6 +572,21 @@ function boost_expire_node($node, $nid = } } + // Get menu and flush related items in the menu. + if (BOOST_FLUSH_MENU_ITEMS !=0) { + if (!isset($node->menu['menu_name'])) { + menu_nodeapi($node, 'prepare'); + } + $menu = menu_tree_all_data($node->menu['menu_name']); + if (BOOST_FLUSH_MENU_ITEMS == 1) { + $links = boost_get_menu_structure_narrow($menu, 'node/' . $node->nid); + } + elseif (BOOST_FLUSH_MENU_ITEMS == 2) { + //$links = boost_get_menu_structure_all($menu, 'node/' . $node->nid); + } + $paths = array_merge($links, $paths); + } + // Get CCK References and flush. if (BOOST_FLUSH_CCK_REFERENCES && module_exists('nodereference')) { $nids = array(); @@ -605,6 +626,7 @@ function boost_expire_node($node, $nid = } } + // Get views containing this node and flush. if (BOOST_FLUSH_VIEWS && module_exists('views')) { $GLOBALS['_boost_router_item'] = isset($GLOBALS['_boost_router_item']) ? $GLOBALS['_boost_router_item'] : _boost_get_menu_router(); $router_item = $GLOBALS['_boost_router_item']; @@ -613,6 +635,7 @@ function boost_expire_node($node, $nid = $data[] = boost_cache_get_node_relationships($relationship); } + // Flush the cache $flushed = 0; if (!empty($data)) { $flushed += boost_cache_expire_router($data); @@ -626,6 +649,59 @@ function boost_expire_node($node, $nid = } /** + * Finds parrent, siblings and children of the menu item. + * + * @param array $menu + * Output from menu_tree_all_data() + * @param string $needle + * Name of menu link. Example 'node/21' + * @param bool $found + * Internal signal for when the niddle was found in the menu array. + * @param bool $first + * Keep track of the first call; this is a recursive function. + */ +function boost_get_menu_structure_narrow($menu, $needle, $found = FALSE, $first = TRUE) { + $GLOBALS['_boost_menu_item_found'] = FALSE; + // Get Siblings + foreach ($menu as $item) { + if ($item['link']['link_path'] == $needle || $found) { + $GLOBALS['_boost_menu_items'][] = $item['link']['link_path']; + $found = TRUE; + } + } + // Get Children + foreach ($menu as $item) { + if ($item['link']['link_path'] == $needle || $found) { + $GLOBALS['_boost_menu_items'][] = $item['link']['link_path']; + $found = TRUE; + } + if (!empty($item['below'])) { + $structure[$item['link']['link_path']] = boost_get_menu_structure_psc($item['below'], $needle, $found, FALSE); + if ($GLOBALS['_boost_menu_item_found']) { + // Get Parrent + $GLOBALS['_boost_menu_items'][] = $item['link']['link_path']; + } + } + else { + $structure[$item['link']['link_path']] = ''; + } + } + + // Clean up + $structure = array_unique($structure); + $GLOBALS['_boost_menu_item_found'] = $found; + if ($first) { + $found = array_unique($GLOBALS['_boost_menu_items']); + unset($GLOBALS['_boost_menu_items']); + unset($GLOBALS['_boost_menu_item_found']); + return $found; + } + else { + return $structure; + } +} + +/** * Return taxonomy terms given a nid. * * Needed because of a weird bug with CCK & node_load() Index: htaccess/boosted1.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/htaccess/Attic/boosted1.txt,v retrieving revision 1.1.2.18 diff -u -p -r1.1.2.18 boosted1.txt --- htaccess/boosted1.txt 30 Oct 2009 15:30:48 -0000 1.1.2.18 +++ htaccess/boosted1.txt 1 Nov 2009 10:15:09 -0000 @@ -51,7 +51,7 @@ # Caching for anonymous users # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request RewriteCond %{REQUEST_METHOD} !^GET$ [OR] - RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR] + RewriteCond %{REQUEST_URI} (^/(admin|logout|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR] RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR] RewriteCond %{HTTPS} on RewriteRule .* - [S=7] Index: htaccess/boosted2.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/htaccess/Attic/boosted2.txt,v retrieving revision 1.1.2.19 diff -u -p -r1.1.2.19 boosted2.txt --- htaccess/boosted2.txt 30 Oct 2009 15:30:48 -0000 1.1.2.19 +++ htaccess/boosted2.txt 1 Nov 2009 10:15:09 -0000 @@ -51,7 +51,7 @@ # Caching for anonymous users # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request RewriteCond %{REQUEST_METHOD} !^GET$ [OR] - RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR] + RewriteCond %{REQUEST_URI} (^/(admin|logout|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR] RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR] RewriteCond %{HTTPS} on RewriteRule .* - [S=7]