Fixed  Error while deleting messages


Well-known member
This happens when someone tries to delete message permanently.

Server Error

Mysqli statement execute error : Out of range value adjusted for column 'position' at row 1

  1. Zend_Db_Statement_Mysqli->_execute()inZend/Db/Statement.phpat line297
  2. Zend_Db_Statement->execute()inZend/Db/Adapter/Abstract.phpat line479
  3. Zend_Db_Adapter_Abstract->query()inXenForo/DataWriter/DiscussionMessage.phpat line948
  4. XenForo_DataWriter_DiscussionMessage->_adjustPositionListForRemoval()inXenForo/DataWriter/DiscussionMessage.phpat line712
  5. XenForo_DataWriter_DiscussionMessage->_postDelete()inXenForo/DataWriter.phpat line1645
  6. XenForo_DataWriter->delete()inXenForo/Model/InlineMod/Post.phpat line118
  7. XenForo_Model_InlineMod_Post->deletePosts()inXenForo/ControllerPublic/InlineMod/Abstract.phpat line125
  8. XenForo_ControllerPublic_InlineMod_Abstract->executeInlineModAction()inXenForo/ControllerPublic/InlineMod/Post.phpat line40
  9. XenForo_ControllerPublic_InlineMod_Post->actionDelete()inXenForo/FrontController.phpat line310
  10. XenForo_FrontController->dispatch()inXenForo/FrontController.phpat line132
  11. XenForo_FrontController->run()in/path/to/docroot/index.phpat line17
I've made a quick fix for RC3, maybe it'll help someone:
in the file library/XenForo/DataWriter/DiscussionMessage.php replace line 944 SET position = position - 1 with this - SET position = IF (position=0, 0, position - 1)


XenForo developer
Staff member
Does it happen anywhere you try to do a deletion? Can you include the exact steps that you used (including the number of which posts you chose to delete and if any of them weren't "visible")?

The error indicates that the values were wrong before. Really, I'd need to see the xf_post.position values for the thread in question. However, the key isn't that they're wrong - it's figuring out why they're wrong.


Well-known member
So here is brief info (that isn't my forum, so that wasn't me, who got that error).

He was trying to delete 33 messages from one thread. As usual, he selected posts and deleted them via inline mod tool. He tried both "safe" deletion (hide messages) and permanent deletion. As the result - that error.

I'm waiting now for access to the DB and for the dump of the posts table from yesterday. As I'll get it - I'll post some more info.


Well-known member
So... I've got some info, but not as much, as I expected.
I have a xf_post table dump, but it is a bit old, so there weren't some posts...
And currently, admin of that web has deleted / moved some posts from that list (IDs I've got form the ACP server error list, text of the error is in the attachment), so it's not possible to find out what was wrong with deleted posts...

So, attached you will find error text and csv files with selection from the dumped table (from backup) and from the current table.

Csv files were made with the next query
SELECT post_id, post_date, message_state, position FROM xf_post WHERE post_id IN (
21678, 21698, 21702, 21705, 21711, 21754, 21774, 21872, 21908, 22005, 22007, 22010, 22038, 22147, 22162, 22187, 22192, 22458, 26123, 26274, 26746, 26786, 26787, 26795, 26797, 26800, 26801, 26807, 26808, 26813, 26816, 26822, 26825



Well-known member
Get one more forum with this error.
Now user tried to delete permanently 316 posts.
See error attached