Open mmcclenn opened 4 years ago
The problem persists for only a few hours, being fixed by the next nightly table rebuild. In addition, it is relatively easy to avoid. Contributors can avoid it by not editing the opinions on a taxon if they have added new children to that taxon earlier in the same day.
Just reverse the workflow, and do all the work on a taxon before starting to add children to it. And if somebody forgets or is unaware of the problem, it will be fixed by the next day anyway.
Editing the opinions on a taxon after children have been added to that taxon during a given day causes temporary corruption of the taxonomic hierarchy. The function moveChildren() in TaxaCache.pm has an off-by-one error that causes the 'left' value for the last child entry in taxa_tree_cache to be adjusted incorrectly. This causes the hierarchy to display with what should be sister taxa appearing as its children.
This problem is fixed by the nightly table rebuild. The parent/child links are not affected, just the tree range fields. And those are discarded and recomputed by the table rebuild code. In fact, the table rebuild pads the left/right values of all entries in taxa_tree_cache, so that the off-by-one error does not cause any problem subsequently.
The only situation in which this error occurs is when new taxa are added and then opinions about the parent taxa are added or edited without any table build intervening. Then the hierarchy for the parent taxon and its children displays incorrectly until the next table build, which happens in the middle of the night (US time).