Closed (fixed)
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
22 Jan 2012 at 10:55 UTC
Updated:
4 Jan 2014 at 01:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dpiIt seems #1359212: EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter() expects the base table to be there has been marked as a duplicate of this issue.
I'm getting PDOException's when changing 'A field attached to this entity' to any value. The field works fine when running as a user with admin role.
Comment #2
rsgracey commentedIn addition to getting the PDO errors, the drop-down select for the fields never saves: It's always the field at the top of the list, which in my case, is always "Body (Value)," regardless of whether I'm logged in as admin or not.
Comment #3
ohthehugemanatee commentedNoting that this error exists for me as well. I'd say it's a simple join missing from the query, but it works as admin...
anyway, this completely breaks the ability to sort by anything other than the base table.
Comment #4
xenophyle commentedIf anyone needs an alternate way of sorting the entity reference nodes, here is a brief description of how I did it using Views. In my example I had a Product node that had an entity reference field that referenced nodes of type Feature.
1. First I created a view with a block display that filters on the Feature content type.
2. Then I added a relationship "Entity Reference: Referencing entity". (This basically means the Feature table is being joined to the Product table.)
3. Then I added a contextual filter "Content: Nid", and I chose from the Relationship dropdown "Content referencing Content from field_features". In your case "field_features" may be something different.
3a. Under "When the filter value is NOT available" I chose "Provide default value" and "Content ID from URL". This means that when viewing a Product page, the view will find the Product's nid in the url and it will show only Features that are referenced by that Product.
4. After saving the view, I went to the block admin page and set the block to display on the desired pages and the desired region.
Comment #5
amitaibuHow about this approach (not tested thoroughly yet)
Comment #6
antonyanimator commentedI get the following error when trying to change an entity reference field on a node with an authenticated user.
It works fine as super user, so I thought it was a permissions issue. However with all permissions turned on for the relation module I still get the error.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node INNER JOIN {node_access} na ON na.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) AND (type IN (:db_condition_placeholder_1)) AND(( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) )OR( (na.gid = :db_condition_placeholder_6) AND (na.realm = :db_condition_placeholder_7) ))AND (na.grant_view >= :db_condition_placeholder_8) ; Array ( [:db_condition_placeholder_0] => 18 [:db_condition_placeholder_1] => products_services [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => all [:db_condition_placeholder_4] => 11 [:db_condition_placeholder_5] => content_access_author [:db_condition_placeholder_6] => 2 [:db_condition_placeholder_7] => content_access_rid [:db_condition_placeholder_8] => 1 [:entity_type] => node ) in EntityFieldQuery->execute() (line 1136 of /home/e-smith/files/ibays/hglass1/html/includes/entity.inc).Comment #7
amitaibu@antonyanimator, is this error after applying the patch in #5?
Comment #8
rainman-2 commented@Amitaibu The patch worked for me! Awesome job.
That's the first patch I've every applied. For future first time patchers, you'll have to follow this guide to clone the entityreference project.
How do we go about submitting this patch so that is can be released in the next version of entity reference? I feel like this functionality is a big deal!
Thanks again, @Amitaibu.
Comment #9
rainman-2 commentedI'm marking this as "reviewed and tested by the community" so we can get this in the next update.
Comment #10
amitaibuCorrect status
Comment #11
damien tournoud commentedMarking as a release blocker.
Comment #12
amitaibuAdding tags.
Comment #13
Taxoman commentedMarked #1567304: File Entity clash (I think) as a duplicate of this issue.
Comment #14
twardnw commentedUsing the scenario in #1359212: EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter() expects the base table to be there I was able to reproduce this.
The patch in #5 applied clean and resolved the error for me.
Comment #15
malberts commentedPatch #5 works for me with entityreference-7.x-1.x-dev (2012-Oct-29).
My scenario: I'm using Commerce with an Entity reference field on the line item form (on the Add to Cart form). My field references nodes and sorts by the title field (not the title property, I replaced it via the title module). I got an error similar to #1359212: EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter() expects the base table to be there when logged out. The patch solves this issue for me.
Comment #16
senpai commentedSounds like comments #14 and #15 make this an RTBC issue. Let's get this patch applied and roll a stable release, shall we?
Comment #17
amitaibuIndeed, that's the last release blocker.
@Damz, are you ok with this patch, and rolling a first stable?
Comment #18
amitaibuCurrent patch in #5 simply skips over the access. We need to try and extract the base table from the query.
Comment #18.0
amitaibuThe patch in comment #5 is RTBC.
Comment #19
amitaibuI'm working on this.
Comment #20
amitaibuLet's see if tests pass.
Comment #21
amitaibuRemoved iterating over conditions, and just add the base-table.
Comment #22
amitaibuAdded test.
Comment #23
amitaibuBetter use assertIdentical() to check the sort order..
Comment #24
amitaibuCommitted.
Comment #25.0
(not verified) commentedUpdated issue summary.