Not a bug XFMG caused a MySQL query error

BredyAK

Member
Licensed customer
Affected version
2.3.7
I got an error log in admin page: XF\Db\Exception: MySQL query error [1264]: Out of range value for column 'position' at row 1 src/XF/Db/AbstractStatement.php:230.

Detailed:
Code:
UPDATE  `xf_post` SET `position` = ? WHERE `post_id` = 360
------------
 
#0 src/XF/Db/Mysqli/Statement.php(207): XF\Db\AbstractStatement->getException('MySQL query err...', 1264, '22003')
#1 src/XF/Db/Mysqli/Statement.php(83): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1264, '22003')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(323): XF\Db\AbstractAdapter->query('UPDATE  `xf_pos...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1412): XF\Db\AbstractAdapter->update('xf_post', Array, '`post_id` = 360')
#5 src/XF/Entity/Post.php(789): XF\Mvc\Entity\Entity->fastUpdate('position', -1)
#6 src/addons/XFMG/XF/Entity/Post.php(40): XF\Entity\Post->postHidden(false)
#7 src/XF/Entity/Post.php(567): XFMG\XF\Entity\Post->postHidden()
#8 src/addons/DBTech/Credits/XF/Entity/Post.php(114): XF\Entity\Post->_postSave()
#9 src/addons/XFES/XF/Entity/Post.php(9): DBTech\Credits\XF\Entity\Post->_postSave()
#10 src/XF/Mvc/Entity/Entity.php(1330): XFES\XF\Entity\Post->_postSave()
#11 src/XF/Service/Post/EditorService.php(201): XF\Mvc\Entity\Entity->save(true, false)
#12 src/addons/HytaleCN/UserContentCheck/XF/Service/Post/EditorService.php(36): XF\Service\Post\EditorService->_save()
#13 src/XF/Service/ValidateAndSavableTrait.php(42): HytaleCN\UserContentCheck\XF\Service\Post\EditorService->_save()
#14 src/XF/Pub/Controller/PostController.php(173): XF\Service\Post\EditorService->save()
#15 src/XF/Mvc/Dispatcher.php(362): XF\Pub\Controller\PostController->actionEdit(Object(XF\Mvc\ParameterBag))
#16 src/XF/Mvc/Dispatcher.php(264): XF\Mvc\Dispatcher->dispatchClass('XF:Post', 'Edit', Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\PostController), NULL)
#17 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\PostController), NULL)
#18 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#19 src/XF/App.php(2824): XF\Mvc\Dispatcher->run()
#20 src/XF.php(806): XF\App->run()
#21 index.php(23): XF::runApp('XF\\Pub\\App')
#22 {main}
 
The error actually happens at a point in the core software:

Code:
#5 src/XF/Entity/Post.php(789): XF\Mvc\Entity\Entity->fastUpdate('position', -1)

Notice the position is being set to -1 which is not a valid value. XFMG does get involved before that but nothing there is overriding anything that would cause the position to be set to -1.

There are other add-ons within the stack trace including HytaleCN/UserContentCheck which may be worth checking.

But, ultimately, it would seem to either be related to some other custom code or conditions within the default XF core code. So I'm moving this to XF bug reports and will await further feedback.

If the issue persists then it's likely just a thread rebuild that's required which can be done at Tools > Rebuild caches > Rebuild threads and make sure "Rebuild position and post counters" is checked.

Or you can run it from the CLI with:

Code:
php cmd.php xf-rebuild:threads --position_rebuild

It's likely that a post somewhere in the thread has a position of 0 when it shouldn't which can either happen as a result of direct modification in the database or importing data from another forum or from some other add-on.

Generally the position rebuild should be done once and the issue shouldn't return.
 
Back
Top Bottom