some of you will have noticed, that even if one has NO access-privileges, drupal continues to show up a menu-entry for that node. if you click on that, you get the "access denied page". that behavior is ugly.

it can be easily fixed by http://drupal.org/node/16542 "Menu rewrite (for node menu items)" and if one has applied http://drupal.org/files/issues/menu_node_access_HEAD_1.patch it is necessary after each grants-modification to clear everytime the cache to rebuild the menu. usually, this will be forgotten and menu-system is not up-to-date.

to avoid this, an automated cache-clear would be nice. to get this, i added the first function and modified the second (in modeaccess.module):

function _nodeaccess_cache_clear() { // copied from devel-module
  // clear preprocessor cache
  drupal_clear_css_cache();
  
  // clear core tables
  $core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');  
  $alltables = $core + module_invoke_all('devel_caches');
  foreach ($alltables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  drupal_set_message('Cache cleared.');
  //drupal_goto();
}

function _nodeaccess_save_new($nid, $grants) {
  db_query("DELETE FROM {nodeaccess} WHERE nid=%d", $nid);
  foreach ($grants as $grant) {
    db_query("INSERT INTO {nodeaccess} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)",
      $nid, $grant['gid'], $grant['realm'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
  }
  _nodeaccess_cache_clear(); // ADDED
} 

Comments

Anonymous’s picture

Status: Active » Closed (won't fix)

This works fine if it's what you need, however since most installations don't require this, I'm not going to incorperate it into the module. I don't like the idea of having code in there that is not utilized by the majority of people, especially since on large installations, clearing the cache can take a while to perform and can have a detrimental impact on site performance.

mantyla’s picture

Status: Closed (won't fix) » Closed (fixed)