0

I have a Structure section that I converted to a Channel. I then tried to delete an Entry Type from the Control Panel and get the following error:

{"error":"SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(`databasename`.`craft_structureelements`.`level` - 2)'\nThe SQL being executed was: UPDATE `craft_structureelements` SET `level`=`level`-2, `dateUpdated`='2019-05-26 04:16:54' WHERE ((`lft` >= 128) AND (`rgt` <= 129)) AND (`root`=21)"}

Upon closer inspection, I'm able to delete many of the Entries of that Entry Type if I delete them directly but there is one that I cannot delete directly which seems to be the source of the error above.

I have found a general discussion of a similar mysql error but I haven't found any Craft specific discussion of this. As I'm trying to make the delete action from the Craft UI, the general solutions are not directly applicable.

Any ideas what might be going on here and what my options are to fix this and get the Entry Type in question deleted without any unexpected side effects?

5
  • The error is because somehow your level value is at -2, when that column only allows for positive integers. No idea how you ended up with a negative level, though. – Brad Bell May 27 '19 at 18:17
  • @BradBell Ok. So, next when I search for any records in the craft_structureelements table with level = -2 I don't find any records. If I search for the specific Element ID causing the issue, the level in the db is 1, which is correct. Any ideas where to look next? Could this be a miscalculation happening in PHP somehow? – Ben Parizek May 28 '19 at 11:42
  • Yeah, hard to say without looking at the database. That table uses the nested set model (en.wikipedia.org/wiki/Nested_set_model) for storing hierarchical data, so my guess would be that somehow that data is out of sync and a calculation is getting set to -2. – Brad Bell May 28 '19 at 19:06
  • Would resaving all entries be a way to resync the data? I'm familiar with nested set but I don't think it would be simple to walk through the lft and rgt values to try to figure out what might be stored incorrectly. – Ben Parizek May 29 '19 at 23:50
  • I don't think so... if you shoot an email over to support@craftcms.com, we've got a script that will let you "visualize" the structure's hierarchy to at least see what sort of shape it is in. – Brad Bell May 30 '19 at 16:22

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.