Comments

ferrari’s picture

StatusFileSize
new743 bytes

Patch to fix this.

cosolom’s picture

amitaibu’s picture

Title: Notice: Undefined property: stdClass::$nid em entity_metadata_no_hook_node_access() » Prevent notice in entity_metadata_no_hook_node_access() when node is not saved
Issue summary: View changes
StatusFileSize
new668 bytes

No, not duplicate of #1780646: entity_access() fails to check node type specific create access

The access() method of the wrapper accepts only 'view' or 'edit'. However, if the node isn't saved yet, we should check for 'create' in entity_metadata_no_hook_node_access()

joshk’s picture

This is required to make use of the wonderful Restful module; any idea what needs to happen for it to be added?

e0ipso’s picture

Status: Needs review » Reviewed & tested by the community

This is working properly.

fago’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/modules/callbacks.inc
@@ -669,6 +669,11 @@ function entity_metadata_field_file_validate_item($items, $context) {
+  if ($op == 'update' && !empty($node) && empty($node->nid)) {
+    // In case checking with the wrapper $wrapper->access('edit'), we need to
+    // convert this to create.
+    $op = 'create';

If the wrapper calls the function wrong, it should be fixed in the wrapper instead. It's not the job of this callback to take care of wrong API usage.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new758 bytes

I will try to run RESTful tests with this one

Status: Needs review » Needs work

The last submitted patch, 7: 2086225-entity-access-check-7.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 2086225-entity-access-check-7.patch, failed testing.

amitaibu’s picture

It seems that tests are currently failing due to testbot issues:

PHP Fatal error:  Cannot redeclare system_requirements() (previously declared in /var/lib/drupaltestbot/sites/default/files/checkout/modules/system/system.install:11) in /var/lib/drupaltestbot/sites/default/files/checkout/sites/default/modules/rebuild/tests/fixtures/drupal_sites/dev/modules/system/system.install on line 518

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 2086225-entity-access-check-7.patch, failed testing.

Status: Needs work » Needs review

roysegall’s picture

StatusFileSize
new1.53 KB

Status: Needs review » Needs work

The last submitted patch, 16: 2086225-entity-access-check-16.patch, failed testing.

roysegall’s picture

StatusFileSize
new1.66 KB

I'm pushing another commit. This one worked on my local machine.

roysegall’s picture

Status: Needs work » Needs review
ckng’s picture

Initial test shows patch #18 is working.

roysegall’s picture

@fago can you please review?

amitaibu’s picture

Status: Needs review » Reviewed & tested by the community

This is working for a few month now on RESTful's simpletests.

e0ipso’s picture

Is there anything I can do to help move this forward?

lukewertz’s picture

I've tested this patch as well and it works great. +1 for merging in the next available release! Thanks!!

Anonymous’s picture

I have also reviewed & tested this with success.

tripper54’s picture

Tested with success, +1 to get this committed!

fago’s picture

Status: Reviewed & tested by the community » Needs work

Sry for letting this lie so long. Parts of the patch confuse me though:


    if (empty($node->vid) && in_array($op, array('create', 'update'))) {
      // This is a new node or the original node.

Why/when would there be no vid when it's the update case? It seems invalid for an update case to have a node without a vid, isn't it? Previously the code here only covered create, why is that changed?

amitaibu’s picture

> Sry for letting this lie so long

No worries, I'm doing worth on my issue queues ;)

if (empty($node->vid)

I think (haven't tested) that it's related to comment about // This is a new node or the original node. We'll check it..

omarlopesino’s picture

Patch #18 works!

I could be need something like this to prevent massive warnings in restful, when I create nodes in POST mode, because for ensure user property access, entity access is called indirectly in 'edit' mode, even when the node is not created yet.

However, I'm agree with @fago, the entity contrib module shouldn't prevent the warnings if there is a bad usage of entity API.

There is something I don't entirely understand, in which real case should be checked entity access in update mode, on a entity which doesn't exists yet? Should not be used 'create' access in that case?

David Hernández’s picture

Status: Needs work » Needs review

Seems that this patch was already applied but this issue was not updated. Can anyone else confirm this?

anthonys’s picture

Yes, looks like this has been applied.

alvar0hurtad0’s picture

+1 the patch is applied on 1.8

alvar0hurtad0’s picture

aron novak’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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