core icon indicating copy to clipboard operation
core copied to clipboard

Deleting a Tag field doesn't remove Tag-Content relationships.

Open joseorsini opened this issue 10 years ago • 3 comments

As a follow-up to https://github.com/dotCMS/core/issues/8793 once we delete a Tag field from a Content Type, existing Tag-Contents relationships stored on this field are still present in the database.

Expected Behavior

Once we delete a Tag-type field, existing Tag-Contentlets relationships tied to this field must be deleted from the DB as well.

Current Behavior

Info related to the field being deleted and tags assigned to contents are still present in the DB. If the field is recreated, data is brought back and available for content editors on all related contents.

Known Workarounds

No workarounds are available for this issue.

Steps to Reproduce

  1. Create a Content Type, called "Test Tag".

  2. Add two fields:

    • Title: Text type, indexed, searchable, show on listing.
    • Custom Tag: Tag type.
  3. Add a content for this new content type (see screenshot 001). Save and publish.

  4. Once it's saved and published, run the following query (replace "e18ba6dd-a879-4717-ab72-5817931ea26d" with your content inode):

# select * from tag where tag_id in (select tag_id from tag_inode where inode = 'e18ba6dd-a879-4717-ab72-5817931ea26d');
                tag_id                |  tagname   |   host_id   | user_id | persona |        mod_date
--------------------------------------+------------+-------------+---------+---------+-------------------------
 bf8e4b34-2151-4494-be98-b2c40ed18099 | testing    | SYSTEM_HOST |         | f       |
 2b3d3aad-4d1a-4241-ada8-e37b91880668 | 123456     | SYSTEM_HOST |         | f       | 2016-10-06 13:30:07.928
 5f93b8d5-fa8a-4bd3-963c-b55feb930a77 | 0987654321 | SYSTEM_HOST |         | f       | 2016-10-06 13:30:07.932
(3 rows)
  1. Go to Content Type, select "Test Tag" and once all fields are listed, delete the Tag field.
  2. Open the content you created, and the Tag field is not there anymore as expected (see screenshot 002). Go back to the DB and run the same query:
# select * from tag_inode where inode = 'e18ba6dd-a879-4717-ab72-5817931ea26d';
                tag_id                |                inode                 |        mod_date         | field_var_name
--------------------------------------+--------------------------------------+-------------------------+----------------
 bf8e4b34-2151-4494-be98-b2c40ed18099 | e18ba6dd-a879-4717-ab72-5817931ea26d | 2016-10-06 13:30:07.934 | customTag
 2b3d3aad-4d1a-4241-ada8-e37b91880668 | e18ba6dd-a879-4717-ab72-5817931ea26d | 2016-10-06 13:30:07.937 | customTag
 5f93b8d5-fa8a-4bd3-963c-b55feb930a77 | e18ba6dd-a879-4717-ab72-5817931ea26d | 2016-10-06 13:30:07.938 | customTag
(3 rows)
  1. Re-create the tag field with the same name, "Custom Tag", and then open the same content you created. Tags will show up (see screenshot 003).

Screenshot 001: Content created.

screen shot 2016-10-06 at 1 30 05 pm

Screenshot 002: Content after the Tag field is deleted.

screen shot 2016-10-06 at 1 35 47 pm

Screenshot 003: Content after Tag field is re-created:

screen shot 2016-10-06 at 1 30 05 pm

Context

Since Fields can share the same Velocity Var Name ONLY on different content types, we need to build a smarter way to store and retrieve Tag-Contents relationships according to a specific field.

Your Environment

  • dotCMS 3.5.1 and 3.6.0.
  • Google Chrome browser.
  • macOS Sierra 10.12.
  • Tomcat app server.
  • Java 8.
  • Postgres 9.4.1

joseorsini avatar Oct 06 '16 17:10 joseorsini

PR: https://github.com/dotCMS/core/pull/9916

agomez-dotcms avatar Oct 07 '16 00:10 agomez-dotcms

@shaydotcms please contact @joseorsini when testing this to see if we can get a large data set with a content type with a tag field and lots of content. Thanks

dsilvam avatar Oct 07 '16 14:10 dsilvam

Passed QA. Tested with started data and using upgrade from 3.6.0 Tested locally in: master-3.7 // Ubuntu 14.04.1 // Postgres 9.3.5 // Firefox

shaydotcms avatar Oct 13 '16 18:10 shaydotcms