Updated: Comment #20

Problem/Motivation

Modules that alter an existing non-configurable field type to be configurable, should also set the provider value to their own name, because field_sync_field_status() will automatically de-activate any field that is of those types and if those types still have Core as their provider. This applies to the email and entity_reference field types.

Proposed resolution

Modules that implement hook_field_info_alter() to make an entity type 'theirs', must also update the provider value.

Remaining tasks

None.

User interface changes

None.

API changes

None.

None.

Comments

plopesc’s picture

Status: Active » Needs review
StatusFileSize
new658 bytes

Attaching patch.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

How do you keep finding all these things? :)

agentrickard’s picture

Having tests in contrib helps. Confirming this patch works.

There is a serious follow-up need, though, as none of the ER tests currenty catch this bug.

agentrickard’s picture

Priority: Major » Critical

This is a release blocker.

aspilicious’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This clearly needs a test

berdir’s picture

The fact that entity_reference still relies on hook_options_list() is a bug on it's own, it is deprecated in favor of AllowedValuesInterface. See #2015687: Convert field type to FieldType plugin for taxonomy module which does this for the taxonomy field.

I also think that "Core" is weird as a provider, IMHO, the component should be in there, maybe core.entity, or something like that. (Wouldn't work here either, of course).

agentrickard’s picture

Do we have a change notice for that conversion? I couldn't find one. I'm ok turning this into a test-only patch issue.

berdir’s picture

There is https://drupal.org/node/2075873.

This might be a valid change, it is arguably the entity_reference.module that provides the configurable entity_reference field type. So this change might be valid. Just saying the reason the actual but here happens is because the field type hasn't been completely converted.

agentrickard’s picture

Thanks.

This fails with Node and User, which both seem to be using the new interface system. It just fails for field widget types other than autocomplete. So I suppose we need tests for that first.

mrconnerton’s picture

I am writing the test for this.

agentrickard’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new714 bytes

Updated patch. This should really go in without a test, as it's an API violation, not a testable bug.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

I agree with that.

swentel’s picture

Related: #2131765: Fields are gone after field info rebuild - more field types suffer from this bug - date and email too.

plopesc’s picture

Title: OptionsWidget is not working for entity_reference field once entity_reference field is defined in hook_field_info_alter() » Field types must use as provider its own module instead of Core when are defined in hook_field_info_alter()
Component: entity_reference.module » field system
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Related issues: +#2131765: Fields are gone after field info rebuild
StatusFileSize
new88.04 KB
new1.06 KB
new370 bytes

Including same line for email module.

Now, all field types are using its own module as provider, as you can see below:

field_provider

Micha1111’s picture

Problem not solved in dev and alpha5 ?

I have added this code line manually in file entity_reference.module:

$info['entity_reference']['provider'] = 'entity_reference';

But the error is still there.

berdir’s picture

Status: Needs review » Needs work

Setting to needs work for tests. Shouldn't be complicated, just take an existing test, rebuild the field information and check that the fields are still active.

plopesc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.52 KB
new3.58 KB
new2.52 KB

Hello.
Patch rebuilding field info in field types affected by this patch to check that they don't dissapear.

I moved the last lines of EmailFieldTest inside an if block because those lines break the testing when $entity is not created.

Regards.

The last submitted patch, 17: field_provider-2115291-17-test-only.patch, failed testing.

xano’s picture

Status: Needs review » Reviewed & tested by the community

One of my (contrib) tests that relied on an ER field failed because of this. Applying the patch solves the patch failures. I also manually confirmed that the field is picked up by field API by checking the UI where it is displayed and be configured.

Setting to RTBC as per #11, #12, and the bot in #17.

xano’s picture

Issue summary: View changes
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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