To reproduce:
- Create a Paragraph bundle
- Add paragraph field to a content type
- Create node of content type and add a new Paragraph
Next, following notices pop up:
Notice: Undefined property: stdClass::$nid in entity_metadata_no_hook_node_access() (line 682 of /Users/xxx/Projects/drupal-7.39/sites/all/modules/entity/modules/callbacks.inc).
Notice: Undefined property: stdClass::$vid in entity_metadata_no_hook_node_access() (line 683 of /Users/xxx/Projects/drupal-7.39/sites/all/modules/entity/modules/callbacks.inc).
Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 683 of /Users/xxx/Projects/drupal-7.39/sites/all/modules/entity/modules/callbacks.inc).
Notice: Undefined property: stdClass::$nid in node_access() (line 3005 of /Users/xxx/Projects/drupal-7.39/modules/node/node.module).
This only occurs during node creation (not during edit) because the nid/vid are not set yet at that point.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | paragraphs-fix_parents_access-2562463-20-7.x.patch | 569 bytes | sebastien m. |
| #14 | paragraphs-fix-parent-access-2562463-14-7.x.patch | 561 bytes | thomjjames |
| #3 | paragraphs-fix-parent-access-2562463-2-7.x.patch | 562 bytes | jeroen.b |
Comments
Comment #2
jeroen.b commentedI'm sorry I got this into a release. We were in a hurry to bring out a security fix.
Does this patch fix it? It turns the $op into 'create' when the entity is new.
Comment #3
jeroen.b commentedI thought of a simpler patch.
Comment #4
vollepeer commentedGreat work, thanks for the quick feedback! Notices are gone, everything seems to be working well now.
Comment #6
jeroen.b commentedComment #8
rp7 commentedIs it possible this issue is back again? Currently using latest dev.
Comment #9
rp7 commentedComment #10
jeroen.b commented@RaF7 can you tell me the line of the notice?
Comment #11
Sebastien VR commentedThis notice is triggered during entity access check on line 285 of paragraphs.module.
This happens when you add a new node that has to possibility to contain paragraphs.
During the paragraph item access check the host entity is being fetched as an object without a 'nid' while node_access() checks if the entity is an object or just a string (ex: node bundle)
Comment #12
jeroen.b commentedWhat version of the entity API are you using?
Comment #13
Sebastien VR commentedHi Jeroen,
Currently i'm using entity-1.6
Comment #14
thomjjames commentedHi,
Getting this issue too with paragraphy fields within a field_collection on a node:
Using Entity API: 1.6, Paragraph 7.x-1.0-rc4 & Field Collection 7.x-1.0-beta11.
Attached patch seems to fix it but not 100% sure of any access implications as I'm not so familiar with this module yet.
Cheers
Tom
Comment #15
socialnicheguru commentedJust noting:
The fix in #5 is not in the present dev version of the module. I also acknowledge that may not be the most appropriate fix any longer
Comment #17
jeroen.b commentedThat could be right. I totally rewrote the access checking because there were quite some issues with it.
@thomjjames, I'm currently trying to get the quality of the code up to par with the D8 version.
That mostly just means we need to add many tests to make sure we won't break anything.
Are you able to create a unit test for this? (and provide 2 patches: 1 with the fixed code + test, 1 with the test only. that way we can see the test actually confirms it is fixed now).
Comment #18
falco010Thanks for patch #14, worked for me
Comment #19
opiSame issue, with latest version of paragraphs (7.x-1.0-rc4) and entity API (7.x-1.8).
Patch from #14 works fine, but I can't tell if it's a good practice to set $host_entity to NULL.
Comment #20
sebastien m. commentedPut $host_entity to NULL is quite huge.
I think to set $host_entity->is_new = true should be enough and could do the job.
Comment #21
das-peter commentedJust stumbled over this issue too.
Patch looks good to me and solves the issue - so I'd say RTBC.
Comment #22
eelkeblokSee #17. We need to get some tests going to cover this.
Comment #23
lorenzs commentedWhen debugging I noticed the $hostEntity actually is a user object instead of a node? Of course this object does not have the 'is_new' property nor a nid...
Can anyone confirm that they also see a user as $hostEntity? This does not seem OK allthough I'm not familiar with this module's code.
But passing a user as 3th arg to entity_access is not correct and adding a 'is_new' to this object (patch #20) is not correct either allthough it fixes the warning...
Comment #24
lorenzs commentedStill have this issue in rc4 with latest entity and entity API modules
Comment #25
xiaodoudou commentedPatch 14 doesnt really fix the issue.
By doing "$host_entity = NULL;" it will break the permission.
You have to do "$host_entity->is_new = true" like said on comment #20.
Thank you to @Sebastien @Actualys !
Comment #26
timme77 commentedPatch in #20 is working for me!
Comment #27
idebr commented@lorenzs #17: The values you are seeing are the default values added by the node module itself, see http://cgit.drupalcode.org/drupal/tree/modules/node/node.pages.inc?h=7.x...
@eelkeblok #22: What exactly do we need tests for? This issue is fixing a notice, not changing any APIs?
Comment #28
eelkeblokThat would be a question for @jeroen.b, I suppose. I was just relaying his request for tests from #17, I had not given the question on how exactly test for this condition any thought (ideally, we *should* be testing for this condition to not occur).
Comment #29
kumkum29 commentedWith the patch #20, it's ok for me !!!
Comment #30
polPatch in #20 fixed the issue. Thanks !
Comment #31
nicholasthompson+1 on #20 too.. worked for me.
Comment #32
matthiasm11 commented#20 fixed the issue.
Comment #33
jstollerI'm increasing the priority of this to critical, as it appears to fix an issue that is causing Paragraphs to fail all automated tests, thus holding up other issues in the queue.
Comment #34
emmanvazz commented+1 on bumping priority on this as it is holding back other issues.
Comment #36
jeroen.b commentedThis indeed does not need tests. Committed, thanks!
Comment #37
polCoool ! Thanks!