I have on some pages a link to: node/[nid]/edit (which only shows up if the node's uid == the current user's uid.), but I do not have an Edit menu item present.
The edit works most of the time, but it sometimes fails with an access denied page.
The problem seems to occur on older pages. The pages can belong to an organic group, but fails whether they are in a group or not.

I hunted the bug down to a call to: _menu_item_is_accessible()
The comment in the code is:
* Determine whether the given menu item is accessible to the current user.
*
* Use this instead of just checking the "access" property of a menu item
* to properly handle items with fall-through semantics.

For some reason the "menu item" is not accessible to the current user. So, even though the user is editing their own page, an access denied is being returned.

The node is a custom module.
I put print statements in the hook_access() and TRUE is being returned.

Can someone tell me if this is really a bug? Is there a workaround? Has anyone run into this before?

These are the things I have tried with no success:
1. Uninstalling, reinstalling non-core drupal modules. (in case of some og_group permissions issue).
2. Emptied all the cache* and sessions tables in the database.
3. Manually examined each row in the database tables looking for the nid of the node I can't edit (Node A), and couldn't find a diffference between that and nodes I can edit (Node B). I may have missed some, so are there some tables I should pay special attention to?
4. Checked all user access controls and they are correct.
5. Post settings: Rebuild permissions

Thanks,
Morgan

Comments

michelle’s picture

When I had access denied errors on two nodes that I just could not figure out it turned out that somehow the nodes had gotten unpublished! I don't think that applies here, since it's the edit tab that's the problem, but I thought I'd mention it just in case.

The other thing I was thinking of is to check the input format(s) in use. If they somehow got changed to a format that the user doesn't have access to, they won't be able to edit the node.

Michelle

--------------------------------------
My site: http://shellmultimedia.com

morganhua’s picture

I think I know what happened. I had a node type that worked fine, except I replaced it with a custom one with some additional fields and I had to remove the old node type and add the custom node type -- with the same node type name. When the old node type was removed, I had the warning about not being able to edit existing nodes of that type. I put the custom node back in and everything seemed to work fine -- except for the edit problem.

tomrue’s picture

Morganhua,

If I read your message correctly, I believe that I'm having the same experience. In Firefox, at http://monticello.tomrue.net/?q=admin/build/menu I get "Error: Host Not Accessible" and in MSIE I get "The page cannot be displayed."

I get the same result at http://monticello.tomrue.net/?q=admin/user/access (Access Control).

This particualar site that I'm talking about is running Drupal 5.1; hosted on my own FreeBSD 6.1 server with MySql 5.0.18, on Apache 1.2.34 and PPH 5.1.2 mod_per/1.29. I had some databasetables crash on another Drupal site (that one running Drupal 4.6.6.6) a couple days ago, which I don't think is at all related to this issue and I only mention it because it was so recent. I fixed that problem and that site seems fine now. I'm haven't been able to figure this other problem out.

I was planning on upgrading my older Drupal sites to the current build, but if it's still buggy I'm wondering if perhaps I should hold off a bit.

If you can help me to figure this out, I'd be grateful. Unfortunately, I don't quite understand what it is that you did when you replaced one node with another; or what custom edits you made. Would you mind clarifying for my foggy mind, please?

Thanks, and a happy spring to you, if we're in the same part of the world.

Tom

--
tomrue.net

P.S. See follow-up in another thread here.

morganhua’s picture

I'm on Drupal 5.1, PHP 5.2, MySQL 5.0.27, Linux and Windows.

I had originally customized a few nodes using Adminster -> Content Management -> Content Type, "Add content type" tab and added a new type called "foobar". Afterwards, I created my own foobar.module. I deleted the content type, whereupon I got a warning message that you may not be able to access or edit nodes of that existing type. I then activated my new foobar.module and voila, everything seemed to work right. I can still see the old customized nodes that were created before I replaced them with my foobar.module. So, I thought everything was ok -- except when you try to edit the old nodes, I get an access denied page.

Another thing I found was that there are some "Variables" accessible via the Devel module -> Variable Editor. These customized variables are used instead of the defaults in the modules. So, even when I edited the modules, things didn't change on the site, until I deleted them.

I learned that there are a lot of caches and other weird places that Drupal hides things. I recommend doing backups of everything both from the top of the directory tree and exporting all the tables in your database. I have discovered many interesting things by diffing the export files.

I don't know if you are building your own custom nodes from scratch or just customizing via the Admin menus.