Fix for a long-standing bug

Due to the way permissions are set up on MacMegasite & WorldBeatPlanet, when a non-administrative user submits a story they’ll get an error ‘access denied’ even though the story is submitted properly. This happens because Drupal tries to display the newly submitted article, which is unpublished. However, non-administrative users can’t view unpublished items, so they get the error. With some digging in the forums at Drupal.org, I found this fix.

In node.module, look for the function node_submit and change the following two lines at the end of the function –

Original:

drupal_set_message($msg);
drupal_goto('node/'. $node->nid);

New:

if (node_access('view', $node)) {
  drupal_set_message($msg);
  drupal_goto('node/'. $node->nid);
}
else {
  return $msg;
}

This verifies that the newly submitted article can be accessed before it attempts to display it.

Comments are closed.