Depth not updated for children when using drag&drop

Created on 3 October 2024, 3 months ago

Problem/Motivation

When updating terms using GUI (drag&drop) children depth_level is not updated.

Steps to reproduce

Create at least 3 terms (parent, child and grandchild), all at root level (term_depth = 1). Then assign parent->child relationship using GUI on taxonomy overview page.

Make sure to move "grandchild" to be under "child" term. Save.

Checking sql:
select tid,name,depth_level from taxonomy_term_field_data

+-----+----------------+-------------+
| tid | name           | depth_level |
+-----+----------------+-------------+
|   6 | Parent         |           1 |
|   8 | Child          |           1 |
|  11 | Grandchild     |           2 |
+-----+----------------+-------------+

This is all good, now drag "child" to be under "parent". Save again. Running the same query as above will return:

+-----+----------------+-------------+
| tid | name           | depth_level |
+-----+----------------+-------------+
|   6 | Parent         |           1 |
|   8 | Child          |           2 |
|  11 | Grandchild     |           2 |
+-----+----------------+-------------+

In this case "Grandchild" should be assigned "depth_level" 3, and not 2.

Proposed resolution

Loop over children and update their depth recursively.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇦Canada igorbiki

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024