I added a field to a vocabulary, then added it to a content_type, I went to remove it from the content_type, went back to the vocabulary to remove it from there also, but it was already removed from there, which was quite unexpected.

Tried it 4 more times, tables renamed in database (as I read it should be for when permanently deleting something), but that begs the question, how does one just remove a field from one thing but not another? There's no extra options under editing, nor any extra links, that I can see.

It feels like the delete link should be on the fields section if it is to remove the field from all content types (which is actually quite a nice idea), with a remove link for the content type/etc. on manage fields section.

(Tried IRC and twitter, searched issues, but no answer on this, but sorry if it's duplicate or I'm missing something; I feel like I am)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hefox’s picture

Category: support » bug

[11:31am] DamZ: hefox: I think the "impossible to delete a field instance" is just
basically a bug
[11:31am] DamZ: hefox: I saw that too

chx’s picture

I think there is a deferred deletion involved which only happens on cron -- it needs to delete the values of the instance but there can be real lots hence this way.

hefox’s picture

(Not sure if you saw my reply on irc)

Yeah, I know about the deferred deletion; noticed it mention in other issue queue post. That isn't the issue.

content type a has field_a

vocabulary b has field_a

Remove field_a from content type a.
field removed from content type a
field ALSO removed from vocabulary b, without deleting it from vocabulary b.

As far as I can tell, there's no way just to remove it from content type a. @.@!

I like having a way to delete the field from anything, but it'd be .. not fun to not have the ability to remove it from just one thing.

I've also tried it when the .. entity? type is the same, ie content_type_a and content_type_b and the behaviour is the same. There was no content at this stage.

webchick’s picture

Priority: Normal » Critical

This sounds critical...

hefox’s picture

Title: No way to remove field instance without removing entire field » No way to remove field instance from a bundle without removing instance from all bundles
Issue tags: +Fields in Core

(adding in fields in core tag and changing title after reading http://drupal.org/node/707832)

yched’s picture

Critical indeed. Will try to look into this later tonight.

yched’s picture

Assigned: Unassigned » yched

LOL @ parenthesis typo : if (count($field['bundles'] == 1)) { delete field } (field_ui.admin.inc)

What do you mean, "it's not funny and how come we don't have a test" ?
Well, you might have a point.

That part needs a bit more care anyway, since after #470242: Namespacing for bundle names, $field['bundles'] is keyed by object type first, so it might have 1 entry but several bundles in it (all for the same object type).

Working on it, and on a test.

yched’s picture

Status: Active » Needs work

Revealed a bug where the sequence

$field = field_info_field($field_name);
field_update_field($field);
$field = field_info_field($field_name);

would cause the $field['bundles'] property, gathered by field_info_field(), to grow with duplicates :

$field['bundles'] = array('node' => array('article', 'article', 'article', ...));

Attached patch should fix this, and the original bug.

No time to add the test tonight, so CNW.

yched’s picture

Right, and the patch.

yched’s picture

Status: Needs work » Needs review
FileSize
15.16 KB

Same fix, with tests.

The patch adds a little sanity to Field UI tests, that are currently a giant single CRUD scenario.
Introduces helper functions to create and delete fields through the UI, and uses them to test 'deletion' separately

As a consequence, patch is kinda big, but the actual code fixes are the same 3k than patch #9.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed #9 and it looks good. #10 adds test sanity and since bot is happy, so am i. rtbc.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome clean-up. Thanks for this yched, and to hefox for the original bug report. :)

Committed to HEAD.

Status: Fixed » Closed (fixed)
Issue tags: -Fields in Core

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