After creating an article node and using the autocomplete tagging widget to add taxonomy terms, the terms are saved to the vocabulary.
However, when re-editing the node, the terms are not available on the node/edit page.
Furthermore, clicking save removes all of the terms from the node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
1.62 KB

Here is a test.
The bug is not in D7, but it could use the test coverage.

tim.plunkett’s picture

FileSize
2.26 KB

Here's the save edit/save code for options_select which passes, proving that it's just the autocomplete that's broken

Status: Needs review » Needs work

The last submitted patch, taxonomy-1754070-2.patch, failed testing.

tim.plunkett’s picture

Priority: Major » Critical

As this can easily cause data loss, this is sadly a critical.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
408 bytes
2.65 KB

This was broken by #1616972: Replace $term->name with $term->label().

Turns out it was a really easy fix!

tim.plunkett’s picture

taxonomy_implode_tags() was switched from
if (isset($tag->name)) {
to
if ($tag instanceof EntityInterface && $label = $tag->label()) {

But without the use statement, the EntityInterface prevented any terms from being loaded.

Status: Needs review » Needs work

The last submitted patch, taxonomy-1754070-5.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
2.66 KB

Whoops, should have been assertRaw.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm #8 corrects the issue. Before applying it, if you entered tags into a term reference field, saved the node, and then edited it again, the field would be blank. After applying the patch, the tags appear correctly in the edit form.

Berdir’s picture

RTBC +1. Fix makes sense and has tests. Backport tag is for the tests, the bug doesn't exist there.

Gábor Hojtsy’s picture

Looks good!

webchick’s picture

Title: Editing and re-saving a node with tagged taxonomy terms removes terms from node » Test coverage for Editing and re-saving a node with tagged taxonomy terms removes terms from node
Version: 8.x-dev » 7.x-dev
Priority: Critical » Normal
Status: Reviewed & tested by the community » Patch (to be ported)

Wow, nice find. Glad we have test coverage for this embarrassing bug now.

Committed and pushed to 8.x. Thanks!

Moving to 7.x for backport of the tests, and reducing in priority as a result.

dcam’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.08 KB

Backported the tests from #8 to D7.

mgifford’s picture

mgifford’s picture

Issue summary: View changes

Assuming this passes, I can't see why this wouldn't be RTBC.

Status: Needs review » Needs work

The last submitted patch, 13: taxonomy-tests-1754070-13.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review
dcam’s picture

That's yet another random test failure. >.>

  • webchick committed 620eaf7 on 8.3.x
    Issue #1754070 by tim.plunkett, dead_arm: Fixed Editing and re-saving a...

  • webchick committed 620eaf7 on 8.3.x
    Issue #1754070 by tim.plunkett, dead_arm: Fixed Editing and re-saving a...

  • webchick committed 620eaf7 on 8.4.x
    Issue #1754070 by tim.plunkett, dead_arm: Fixed Editing and re-saving a...

  • webchick committed 620eaf7 on 8.4.x
    Issue #1754070 by tim.plunkett, dead_arm: Fixed Editing and re-saving a...

  • webchick committed 620eaf7 on 9.1.x
    Issue #1754070 by tim.plunkett, dead_arm: Fixed Editing and re-saving a...