Hello, sorry to flag another bug, but I've suddenly started seeing these messages while in the Structure menu of Drupal. The only thing I did previous to this was to add a node reference field to a Drupal user (not through a module, through the core functionality in Drupal under the Configuration > Account settings menu).
Notice: Trying to get property of non-object in nodeaccess_nodereference_node_grants() (line 28 of /Applications/MAMP/htdocs/dummy_dru_2/sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
Notice: Trying to get property of non-object in nodeaccess_nodereference_node_grants() (line 28 of /Applications/MAMP/htdocs/dummy_dru_2/sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/dummy_dru_2/includes/common.inc:2561) in drupal_send_headers() (line 1040 of /Applications/MAMP/htdocs/dummy_dru_2/includes/bootstrap.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULLAND field_data.nid = '3'' at line 1: SELECT DISTINCT field_plot_which_farm_nid AS reference FROM {field_data_field_plot_which_farm} WHERE field_plot_which_farm_nid IS NOT NULLAND field_data.nid = :nid ; Array ( [:nid] => 3 ) in nodeaccess_nodereference_get_referenced() (line 224 of /Applications/MAMP/htdocs/dummy_dru_2/sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
Comments
Comment #1
danielb commentedI fixed that SQL error, but I can't replicate the other stuff. I added a node reference field into user accounts, and edited a user and gave him a reference, browsed around a bit, rebuilt permissions, etc.. never saw those messages.
Comment #2
jbucks commentedOK, thanks! I'll give the update a try, and will report back if I still get the messages or if it's working. Thanks again!
Comment #3
jbucks commentedHm, looks like I'm still getting similar messages:
I should mention I'm also using Node Access User Reference 7.x-3.1. This time I had created a single content type with both a node reference field and a user reference field (this time I didn't create a node reference field on a user, I did it the other way around). Then I assigned a user to an instance of that content type, then I logged in as that user to create some content. After logging in, I got this message:
Notice: Trying to get property of non-object in nodeaccess_nodereference_node_grants() (line 28 of /Applications/MAMP/htdocs/stadtgarten/trunk/sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
I then tried to create, with that user, an instance of another content type. On submitting it, I got the following messages:
* Notice: Trying to get property of non-object in nodeaccess_nodereference_node_grants() (line 28 of /Applications/MAMP/htdocs/stadtgarten/trunk/sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
* PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data.nid' in 'where clause': SELECT DISTINCT field_farm_organization_nid AS reference FROM {field_data_field_farm_organization} WHERE field_farm_organization_nid IS NOT NULL AND field_data.nid = :nid ; Array ( [:nid] => 1 ) in nodeaccess_nodereference_get_referenced() (line 224 of sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
Comment #4
jbucks commentedI just tried a clean install of Drupal 7, and installed and enabled only the following modules:
- Backup and Migrate 7.x-2.1
- chaos tools 7.x-1.0-alpha2
- Views 7.x-3.x-dev
- References 7.x-2.x-dev
- Node access node reference 7.x-1.11
- Node access user reference 7.x-3.1
I then created an Organization content type, and gave this a user reference to users with a role of Owner. I then create a dummy user with that role. Next, a content type of Department, which I gave both a user reference to Members and a node reference back to Organization.
I then logged into Drupal as the dummy user, and after doing so I received the following notice:
Notice: Trying to get property of non-object in nodeaccess_nodereference_node_grants() (line 28 of sites/all/modules/nodeaccess_nodereference/nodeaccess_nodereference.module).
After trying to create new content with that dummy user, I got the same error messages as in my post number #3.
Thanks again!
Comment #5
danielb commentedOh yep I'm getting it too now, looks to be because $cached_grants->data is accessed too early, before the checks for whether $cached_grants is empty.
I'll get onto that soon.
Comment #6
danielb commentedComment #7
jbucks commentedWow, thanks, so far no more error messages, thanks a for fixing these bugs!
I do have another query, but it's about the use of this module.
I don't seem to be properly limiting node access: As above, I have the Organization content type, and underneath that another content type called Department with a node ref field pointing to Organization. The site admin creates Organizations, and assigns users with an Owner role to them. Owners have permissions to create, edit, and delete any of their own Departments or by Departments by other Owners.
The desired behavior is that these permissions apply, but only within the Organizations that the Owners belong to.
For example: Organization 1 is owned by Bob and Sue. Organization 2 by Rob. Bob and Sue should be able to create Departments within Org 1 and edit Departments that either of the two owners create, but not to create or edit Departments within Organization 2.
Right now, this isn't working, any Owner can edit any Department, regardless of whether they have access to other Organization nodes or not.
My settings:
Organization has a user reference to users with the Owner role (I've tried various combinations of the node access user reference settings)
Department has a node reference to Organization (again, tried various combinations of the settings of the node access node reference)
1 - What takes precedence - node access node reference, or Drupal role permissions?
2 - Does this module work with the References module's ability to use Views to filter options within fields? For example, I created a View which finds the Organizations that a logged in Owner belongs to, and when an Owner creates a Department content type and has to choose an Organization that the Department belong to, only the Organizations the Owner has been assigned to show up as options for that field.
3 - Are there any tutorials/documentation of how to use this module properly, as maybe I'm not doing something correctly?
Thanks once again!
Comment #8
danielb commentedI don't know how to explain this in terms of 'precedence', but basically you need both the permission and the node access. If you don't have the permission the node access will never work, and if you have permission then you will still need node access.
Yes, it doesn't make a difference how you filter the node reference options, you will still ultimately be saving node references, not anything from views.
Nope, I try to include everything in the readme and interface.
As for your scenario - what settings have you used? You say you have tried various settings, but what is your ideal configuration? Can an owner edit their own organisation, or does the access to the departments get based on their view access? Can an owner view other owner's organisation nodes?
Have you used the devel node access module at all to see if grants are set?
Comment #9
jbucks commentedThanks for the reply!
Yes, Owners should be able to edit everything in their own Organization, including Departments which have been created by Owners of the same Organization. But Owners of one Organization shouldn't be able to edit any other Organizations or Departments of other Organizations.
So on the Organization content type with the user ref field_owners, I checked all of the 'node access user reference settings:
grants for referenced user:
- view, update, delete: all checkboxes checked (I'm assuming here that because the referenced users will be Owners who I specify when creating an Organization, these should have access to fit my scenario above)
grants for author:
- view, update, delete: all checkboxes checked
grants for all users:
- view checkbox is checked (I assume this means that other Owners can view, but not change this organization.)
Now the Node Access Node Reference settings in my Department content type (which has a node ref field_organization which points to the Organization type). I'm guessing that the user ref settings above set for Organization are passed to the Department content type using node access node reference, is that right?
grants from referenced node:
If a user has view access, then I pass on only view access,
if a user has update access, then I pass on view, update, delete access
if a user has delete access, then I pass on view, update, delete access
grants for author:
- all checkboxes checked
grants for all users:
- view access checked
Hopefully this is all clear, and once again, thanks a ton for all your help!
Comment #10
danielb commentedThat sounds right to me.
Comment #11
jbucks commentedHm, I installed Devel to have a look. The only thing that seems to be working is when I select and deselect 'view' for the node access settings on a field. I'm not sure what the problem is...
To use a simpler example - On a content type Org I add a user ref field to users with role Owner. In Permissions, I give the Owner role permissions to create, edit own content, edit any, delete own, delete any. I created a few Orgs with different Owners.
When I looked at a node, in the Devel table on that page titled 'Access permissions by user', all users showed the message 'YES: by node (permissions)+' for the create, update and delete columns. But Owners should only have node access for the nodes they are referenced in?
I also tried looking at nodes with Devel in my example in #9 to see if node access node reference did the same thing, and yes, same result.
At this point I'm not sure how to get this working, and if it's something basic I'm stupidly doing wrong, or if it might be a bug? I tried all this with a clean install of Drupal and database, with only Devel and the node access modules plus References...
Comment #12
jbucks commentedI should add that my example in #11 that, for the node access settings of user ref field, I selected only 'view' for referenced users, author, and all users.
Comment #13
jbucks commentedOK, so far I've sorted the problem. I misinterpreted what you wrote about permissions; I thought that I had to ALLOW all permissions for one of the content types in question and that node access would then work, but actually it was the reverse; I had to REMOVE every permission (except Create) in Drupal for that content type, and then node access works.
My apologies for all my queries, thanks again for your help, and for the great module!