Trouble editing Drupal nodes? Check your input formats!

I ran into an annoying problem today where members of a certain administrative role could not edit nodes on a Drupal site.

I checked the following:

  • The role had administer nodes, which should have given members the ability to edit any node.
  • The role had the edit foo permission and the edit own foo permission.
  • I tried getting rid of edit own foo in case it was conflicting with edit foo.
  • I reset the node_access table.
  • I emptied the cache.

Nonetheless, some nodes were editable, and some were not. Normally Drupal is very robust, and I just couldn't figure out why things were not working.

Finally, distraught, I went into the node module's code at http://api.drupal.org/api/file/modules/node/node.module/5 and clicked into the node_access function. Lo and behold, right at the top, it hit me like a brick:

  // If the node is in a restricted format, disallow editing.
  if ($op == 'update' && !filter_access($node->format)) {
    return FALSE;
  }

All of the nodes that I could not edit had been switched to use the Full HTML input format. I gave the role in question permission to use that input format, and I was good to go.

So there's the lesson for the day: if you can't edit a page, check the input format.

Hope this saves you from pounding your head against a desk like I did this afternoon.

Comments

Be careful to not just give

Be careful to not just give anybody full html access. This is a permission which should only be given to people known to be trustworthy as it will open a lot of possibilities to gain more rights than you intended to give them.

Just ran into this old issue

Just ran into this old issue this morning: http://drupal.org/node/91663 - we should definitely ge it fixed in Drupal 7.

I ran into the issue a while

I ran into the issue a while ago too. Back then, I found a blog post on the Exodus Development site that saved me some troubleshooting time. There's a patch in the queue that addresses the issue.

I've also spent time in the

I've also spent time in the past diagnosing this problem. I think lennart is onto something - it would do wonders if Drupal reported the reason for Access Denied errors so it would be easier for admins to diagnose problems like this.

Yes. I also spend some time

Yes. I also spend some time figuring that out once. It would be nice if the system explained why it will not let a role edit. Than you would know right away and just go and give that role permission to use the filter in question. UI improvement.