Index: node.module
===================================================================
--- node.module	(revision 3905)
+++ node.module	(working copy)
@@ -2259,7 +2259,17 @@
  *   and assumes the caller has already performed a mass delete of some form.
  */
 function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
-  if ($delete) {
+  // Prevent deletion of node access table entries if node id is not existing. Otherwise the node id will be interpreted as 0
+  // wiping out access for all anonymous users, see http://drupal.org/node/282555.
+  if ($delete && !$node->nid) { 
+    $node_url = url($_REQUEST['q'], array('absolute' => TRUE)); // calculate referrer link
+    // maybe the node title is still there, giving it a try doesn't harm
+    $msg = t("Node access grants for node @title couldn't be wiped out as node id is not existing!", array('@title' => $node->title)); 
+    // write error message to screen and watchdog
+    drupal_set_message($msg, 'error');
+    watchdog('node', $msg, array(), WATCHDOG_ERROR, $node_url);
+  }  
+  elseif ($delete) {
     $query = 'DELETE FROM {node_access} WHERE nid = %d';
     if ($realm) {
       $query .= " AND realm in ('%s', 'all')";
