Just noticed with the new permissions that there is a access_create little bug throwing

Recoverable fatal error: Object of class stdClass could not be converted to string in domain_node_access_create() (line 2113 of /sites/all/modules/domain/domain.module).

$permission = "$op $node content on assigned domains";

Send a patch in a sec

Comments

joelpittet’s picture

StatusFileSize
new591 bytes

Probably didn't need a patch for this one but there you go, nonetheless

Joel

joelpittet’s picture

Well that patch doesn't solve the problem but it reduces it from a Fatal Error to a notice:

Notice: Trying to get property of non-object in domain_node_access_create() (line 2113 of /sites/all/modules/domain/domain.module).'

I will dig a little deeper for where the args are being passed in.

joelpittet’s picture

StatusFileSize
new1.56 KB

Ok this is a better patch, based on the hook_node_access

* @param $node
*   Either a node object or the machine name of the content type on which to
*   perform the access check.

hook_node_access($node, $op, $account) {
  $type = is_string($node) ? $node : $node->type;
agentrickard’s picture

Status: Active » Needs review

I cannot replicate this error under normal circumstances. (e.g. a user tries to add content at node/add/article.

The 'create' operation for node access is supposed to pass $node as a string, not an object. Core is very clear about this.

What are you doing when this happens? What module is passing an object?

agentrickard’s picture

Status: Needs review » Postponed (maintainer needs more info)

Proper status. Please set patches to 'needs review' when you post them.

skizzo’s picture

I am seeing the same error on Domain 7.x-3.1
The error shows up when previewing an Article before submission.
If I submit the article without previewing no error is reported.

joelpittet’s picture

That is exactly where I was seeing there too. I couldn't pin point the cause but it is possibly an issue in core. Although the hook doesn't tell you if it's an object or a type string as its param and makes note to test this in the example. This was the reason and solution for my patch.

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Needs review

It's a problem with the preview phase that we need to account for. We should check for core issues, too.

joelpittet’s picture

I was reading through the code and they are very liberal with what they toss into that node_access('create', $node/$type) call on the second param.

book_node_view_link has string $child_type #94 book.module
_node_add_access() has $type->type string #1854 node.module
forum_menu_local_tasks_alter() has node object #176 forum.module
node_preview() has node object #330 node.pages.inc
translation_node_overview() has node object #56 translation.pages.inc
comment_notify_form_alter() has string $type #334 comment_notify.module
ctools_node_access_ctools_access_check() has string $node_context->data->type #61 node_access.inc
pathauto_blog_update_alias has string 'blog' #749 pathauto.module

Their implementation of the hook does what I have in that patch.
node_node_access #2931 node.module

agentrickard’s picture

Yes, the problem with the original report is just that it did include seps to reproduce the error. I never hit the Preview button.

joelpittet’s picture

Yeah sorry, didn't spot when it was occurring because I got the message passed from a client and only saw it infrequently myself so it was hard to include where it came from in the original post. The code was the only thing I had to go on.

agentrickard’s picture

StatusFileSize
new2.39 KB

And a patch that reduces some code duplication.

joelpittet’s picture

I like that refactor. Maybe also consider changing the param name $node to $node_type or just $type to alleviate any confusion to what it's getting?

agentrickard’s picture

$node is the node object or string passed by node_access(). $type might be renamed to $node_type, but I find it clear now.

joelpittet’s picture

Oh I see what you did there now, looks good.

agentrickard’s picture

Status: Needs review » Fixed

Committed. Only affects 7.x.3.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.