0

This is a partial duplicate of a direct support request raised through email.

I have 2 Structure sections that have been behaving just fine in Craft 3.1.32.1:

  • One of them continues to be fine
  • But the other has become a hierarchical mess of randomness, and any attempts to drag entries into the correct hierarchy frequently generate an "unknown error" message.

I have taken steps to isolate what happens by clearing caches, emptying /storage/logs, doing a specific entry drag and drop which generates an error, and sending the resultant web.log to Craft Support.

The purpose of this thread is to ask how I might fix this at the database level.


I can see that the structureelements table has columns for:

  1. structureId
  2. elementId
  3. root
  4. lft
  5. rgt
  6. level

Fields 1, 2 and 6 are self-evident but it's not clear to me what fields 3 to 5 do.

Furthermore, for example…

In the Structure section that is working fine, I have an entry #654 that is a level 2 child of entry #786 but I cannot see the latter referenced in the structureelements row for #654.

Any pointers much appreciated.


Update: Oli at Craft has pointed me at nested sets (thanks).

For my 2 example entries cited above (from the Structure that continues to work without error) I have:

|id|structureId|elementId|root|lft|rgt|level|
|--|-----------|---------|----|---|---|-----|
|41|2          |786      |31  |4  |13 |1    |
|35|2          |654      |31  |5  |6  |2    |

Still not sure what the values of 4, 13, 5, and 6 key into – and therefore how I might go about fixing the Structure section that is broken.


In case it is of relevance, the Structure that is working fine only has live enabled entries in it, but the Structure that is broken has lots of disabled entries. It seems unlikely that is relevant as the now broken Structure was working fine for quite a while with disabled entries.

  • Still hopeful that someone with knowledge of Craft's DB schema will point me in the right direction. To cite my example rows, there must be somewhere in the database that ties structureelements row #35 to row #41 right? But where? Or is it obfuscated in a hashed value somewhere? – Jonathan Schofield Jul 4 '19 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.