I have used entity reference on several sites for nodes and not had too much problem with it. I decided to test out ECK (entity construction kit) and use it with node-to-eckentity references.

I have a node content type called "task" and entity type called status. A task references a status, but nothing will show up on the node view page for that field.

I made a quick screencast showing the issue: http://www.screencast.com/t/jaKjDnp3S6

Everything seems to work fine except for the display on the node (view) and in views.

This is on vanilla Drupal 7.10... nothing else enabled but eck, entity reference, and dependencies of those.

Comments

ff1’s picture

Great screencast!

I have exactly the same bug on my site and can confirm everything that was said in the screencast.

ff1’s picture

Project: Entity reference » Entity Construction Kit (ECK)
Version: 7.x-1.x-dev » 7.x-2.0-alpha1

After thinking about it, this problem is more likely to be due to ECK, so I'm re-assigning it.

fmizzell’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Status: Active » Fixed

the problem was with access.. entityreference calls entity_access from the entity api module, which in turn looks for an 'access callback' defined in the entity_info array. I added the access callback to the info array and now everything works as expected. Make sure you clean your cache to rebuild then entity_info array. Cheers

ff1’s picture

Status: Fixed » Needs work
StatusFileSize
new35.79 KB
new19.02 KB

Sorry, I don't think this is fixed yet...

I've installed the latest -dev version and flushed all caches, but I still can't get this to work. See below...

Edit screen

So far, so good. The enitity is created with a simple reference field to another bundle. In the edit screen, I'm able to select a referenced entity (Car in the screenshot). However, when I save and view the entity, the following error messages appear and the reference field is still not displayed. The same error messages appear if I try to show a view that lists the entity reference field.

Error messages

Hope this all makes sense.
Thanks

acrazyanimal’s picture

I just ran into this same problem (entity reference not displaying for eck entities) and eventually traced it back to here. Glad to see its already being addressed. This access issue is causing other problems as well that I've noticed, but haven't reported to ECK yet. It also prevents rules access to properties and views bulk operations from being used if the rules try to modify eck entities.

So ... we should try and fix this. I guess its time to address #1374150: Better Permissions

I'll see where I can get with this.

acrazyanimal’s picture

Ok so I see what happened there, you put in user_access, but that won't do what you think it will. The entity api uses its entity_access function which is simply the following:

<?php
function entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
  if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
    return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);
  }
}
?>

So the variables passed to the access callback don't match what user_access would be expecting. What we need to do is implement a proper callback function. In the interim till there is time to do this we can just return true.

Here is a patch that should work.

acrazyanimal’s picture

Status: Needs work » Needs review
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Seeing the same errors as #4, patch in #6 works for me.

ff1’s picture

The patch in #6 appears to be applied to 7.x-2.x already. This is great as it fixed the problems that I described in #4. Thanks!

ff1’s picture

Status: Reviewed & tested by the community » Fixed
ff1’s picture

Status: Fixed » Reviewed & tested by the community

Sorry, ignore me! The patch in #6 is not yet applied. I was having git trouble :P

Anyway, the main thing is the patch fixed the problems. Thanks.

acrazyanimal’s picture

np.

However be aware that there are security implications for this. As long as you are using ECK interfaces for the collection and display of your entity data then ECK can control their respective access. However, if you are using views or rules integration then the access checks for each field and entity will return true so you will have to ensure you use views and rules access settings to control who should, or should not, view the data in your ECK entities.

We will eventually implement a much better solution, but for now this is getting the ball rolling.

fmizzell’s picture

Status: Reviewed & tested by the community » Fixed

The patch has been commited

Status: Fixed » Closed (fixed)

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

  • Commit 0488ae0 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x by fmizzell:
    #1512950 No referenced content display foe ECK entities
    
    
  • Commit f3567f2 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x authored by acrazyanimal, committed by fmizzell:
    #1512950 No Referenced content display for ECK entities
    
    

  • Commit 0488ae0 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x by fmizzell:
    #1512950 No referenced content display foe ECK entities
    
    
  • Commit f3567f2 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x authored by acrazyanimal, committed by fmizzell:
    #1512950 No Referenced content display for ECK entities
    
    

  • Commit 0488ae0 on 7.x-2.x, 7.x-3.x, 8.x by fmizzell:
    #1512950 No referenced content display foe ECK entities
    
    
  • Commit f3567f2 on 7.x-2.x, 7.x-3.x, 8.x authored by acrazyanimal, committed by fmizzell:
    #1512950 No Referenced content display for ECK entities
    
    

  • Commit 0488ae0 on 7.x-2.x, 7.x-3.x, 8.x by fmizzell:
    #1512950 No referenced content display foe ECK entities
    
    
  • Commit f3567f2 on 7.x-2.x, 7.x-3.x, 8.x authored by acrazyanimal, committed by fmizzell:
    #1512950 No Referenced content display for ECK entities