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.