Just noticed the following problem on NEW NODES. When using the entity reference auto-complete we get the 403 ajax error listed below.

To get around this problem we can create and save a node, then edit it. When we follow that workflow the error no longer occurs.

This has been tested with various 'ENTITY SELECTION' methods (simplified and entity reference views).

Removing line 1030 of entityreference.module solves the problem but not entirely sure of the repercussions of this.

-------------------

An AJAX HTTP error occurred.
HTTP Result Code: 403
Debugging information follows.
Path: http://localhost/entityreference/autocomplete/single/field_videos/node/v...
StatusText: error
ResponseText:
Site Search | Television Academy
@import url("http://localhost/modules/system/system.base.css?nabcnu");
@import url("http://localhost/modules/contextual/contextual.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/date/date_api/date.css?nabcnu");
@import url("http://localhost/sites/all/modules/custom/emmys_admin/top-button.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/entityreference_live_preview/...");
@import url("http://localhost/modules/field/theme/field.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/freepager/freepager.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/views/css/views.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/admin_menu/admin_menu.css?nabcnu");
@import url("http://localhost/sites/all/modules/contrib/

Comments

DanielWashbrook’s picture

Hi Sill, it looks like the issue is a case sensitivity one. On line 1025 of entityreference.module
if ($entity_id !== 'NULL') {
when a new node is being used, $entity_id = 'null' so this condition becomes true when really it should be false.

Any idea if fixing the case on this condition will have effects elsewhere?

andreasoby’s picture

Did anyone ever solve this issue?

couloir007’s picture

This is happening to me when Entity Reference in paragraphs. When I initially add a new paragraph, I can add references, as many as I want. As soon as I save the content, I get this error when I update. Both $has_view_access and $has_update_access are returning false. The difference is that $entity_id is not being set on the initial add paragraph, and it is being set when editing an existing item. $entity_type = 'paragraphs_item' and $entity_id is a paragraph item id. This doesn't seem right to me. I can avoid this by changing line 1025 to if ($entity_id !== 'NULL' || $entity_type !== 'paragraphs_item') {

Thank you.

capellic’s picture

My use case is slightly different. I have a node that has a Paragraph field on it. I add a Paragraph Bundle that has an entity reference field. When I create the node, no problems. But this is a multilingual site and so when I translate the node into French and then start typing the name of a French node, I get the 403 error being discussed above.

jimafisk’s picture

Removing return menu_access_denied; on line 1030 of entityreference.module removed the AJAX error for me. Seems like this might not be the most sustainable / safe thing to do.

This isn't much better, but you can accomplish something similar by changing lines 1027 and 1028 to:

$has_view_access = ($entity_type == 'paragraphs_item' ? TRUE : (entity_access('view', $entity_type, $entity) !== FALSE));
$has_update_access = ($entity_type == 'paragraphs_item' ? TRUE : (entity_access('update', $entity_type, $entity) !== FALSE));

The proposed fixes in #1 and #3 to line 1025 didn't seem to work for me.

couloir007’s picture

To update this ongoing issue, a little more context, my entity ref field is in a paragraph within a paragraph. Not sure this is relevant. #5 works and it is now 1083 and 1084.

Kasey_MK’s picture

I'm having a similar problem. I have an entityreference autocomplete field when adding an image (in the media browser) to a paragraph field. The same field on the node itself works fine for all users, but the one in the paragraph/media browser gives a 403 AJAX error to authenticated users.

Removing return menu_access_denied; on line 1088 of entityreference.module removed the AJAX error, but as noted that's a bad idea.

None of the other solutions put forward on this page worked for me either.

joanpebupe’s picture

I was facing a similar behaviour as described in #3 @KaseyMK maybe it is similiar to yours. Have you tried to enable the paragraphs_bundle_permissions module, which comes inside paragraphs module?

I solved in this way.

jimafisk’s picture

#8 seemed to fix this issue for my site. Thanks joanpebupe!

brandon_by_brandon’s picture

#8 works for me. Its just strange it was not a problem until recently.

farse’s picture

The problem occurred for me when I was trying to use an entity reference on a draft page.
In theory #8 worked for me too but instead of using the module I copied the paragraphs_bundle_permissions_paragraphs_item_access hook and put it in my own custom module with a couple of simple rules because I just have so many bundles on the site the permissions would of been a nightmare.

Kasey_MK’s picture

Weirdly, this problem had gone away for me and just came back... but the solution in #8 worked for me too. Thanks @joanpebupe