This isn't really a problem as it still works, but it does kick up a lot of warning messages in the log so I just thought I'd ask about it here. I've checked the fields and the views many times and they both seem to be setup correctly.

Does anyone have any ideas why this is happening? Will these constant log entries slow down the site once more users are on there?

Thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ron_s’s picture

I've noticed this too as of late. Seems to specifically be when users are editing forms that were previously saved, and the form has an Entity Reference field on it.

Haven't had the time to track down what might be causing it, but does not seem to cause functional issues.

ron_s’s picture

Title: Log warning message 'The view [my view name] is no longer eligible for the [my field name].' » Views roles + Field Permissions support (watchdog: view is no longer eligible for field)

Ok, just checked the code and this seems to be a bug. This is a case of limiting roles on a View, and in my case, combined with using Field Permissions on an Entity Reference field.

Only certain roles can access the Entity Reference view, and I'm using Field Permissions to limit who can access the field on the entity type. Admins have the ability to use and access the entity reference field, but regular authenticated users do not.

The problem stems from the code in the initializeView function in EntityReference_SelectionHandler_Views.class.php:

  protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) {
    $view_name = $this->field['settings']['handler_settings']['view']['view_name'];
    $display_name = $this->field['settings']['handler_settings']['view']['display_name'];
    $args = $this->field['settings']['handler_settings']['view']['args'];
    $entity_type = $this->field['settings']['target_type'];

    // Check that the view is valid and the display still exists.
    $this->view = views_get_view($view_name);
    if (!$this->view || !isset($this->view->display[$display_name]) || !$this->view->access($display_name)) {
      watchdog('entityreference', 'The view %view_name is no longer eligible for the %field_name field.', array('%view_name' => $view_name, '%field_name' => $this->instance['label']), WATCHDOG_WARNING);
      return FALSE;
    }

The line right before the watchdog statement is causing the issue. It says the message is to be written if !$this->view->access($display_name). Unfortunately this will be the case for any entity reference field that has restricted Views roles, and uses the Field Permissions module to give access to select users.

Modifying the issue title to more accurately reflect the problem.

ron_s’s picture

Version: 7.x-1.1 » 7.x-1.x-dev

I see this same code exists in 7.x-1.x, so marking this as an issue with the -dev branch.

http://cgit.drupalcode.org/entityreference/tree/plugins/selection/Entity...

sozonov’s picture

Also you should check views access permissions!

NWOM’s picture

This problem also occurs when importing nodes via Feeds, even when the entity reference field is not mapped.

possiBri’s picture

Has this been fixed in dev?

seanr’s picture

It has not - still seeing the same code for that function.

blueblot’s picture

I'm experiencing the same problem specifically when a user edits a form that was already saved.

I have an entity reference to users and the data in this reference is gone after the formedit.

Collins405’s picture

Same issue here, its actually not causing any functionality issues, just flooding Watchdog

Collins405’s picture

Can anyone have some input or suggestions for suppressing this error?

It's the same scenario for us, we use field permissions to restrict an entity reference field from certain roles, and whenever a user with the role creates an entity with that field, this error spams watchdog.

nickonom’s picture

Status: Active » Closed (works as designed)

You need to adjust the view permissions. See https://drupal.stackexchange.com/questions/258358/views-roles-field-perm... for details.

NWOM’s picture

Status: Closed (works as designed) » Active

@nickonom: This doesn't have anything to do with standard Views Access permissions.

alan-ps’s picture

Status: Active » Needs review
FileSize
2.53 KB

The issue is still present. It does kick up a lot of warning messages in the logs as mentioned in a description. So, I think it would be great to fix this.

The source of a problem was already described in #2. I would like to add that the access check (!$this->view->access($display_name)) was introduced here:
https://www.drupal.org/project/entityreference/issues/1253776#comment-59....

The access function also determines if the given user has access to the view (not only if it is disabled), and this does not look as a point to log such warnings. We probably should fix this.

Please check the patch attached to this comment. It should help with to solve this issue.