• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Field 'draft_id' doesn't have a default value.

#1
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Field 'draft_id' doesn't have a default value - library\Zend\Db\Statement\Mysqli.php:214

Do you know what might cause this and how to fix it?
 
#3
#0 D:\home\site\wwwroot\library\Zend\Db\Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
#1 D:\home\site\wwwroot\library\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 D:\home\site\wwwroot\library\XenForo\Model\Draft.php(47): Zend_Db_Adapter_Abstract->query('\r\n\t\t\tINSERT INT...', Array)
#3 D:\home\site\wwwroot\library\XenForo\ControllerPublic\Thread.php(746): XenForo_Model_Draft->saveDraft('thread-1013', 'A few effects t...', Array)
#4 D:\home\site\wwwroot\library\XenForo\FrontController.php(351): XenForo_ControllerPublic_Thread->actionSaveDraft()
#5 D:\home\site\wwwroot\library\XenForo\FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#6 D:\home\site\wwwroot\index.php(13): XenForo_FrontController->run()
#7 {main}
 

Chris D

XenForo developer
Staff member
#5
Did you ever have an add-on or currently have one installed that was related to drafts in any way?

The error should be impossible because the draft_id field should be set to AUTO_INCREMENT. Have you made any changes at all to MySQL?

Are you able to run these queries and let us know the result?

Code:
SHOW CREATE TABLE xf_draft;
Code:
SELECT * FROM xf_draft WHERE draft_key = 'thread-1013';
Does this always happen when saving a draft post in a thread?
 
#6
When does this error occur?
I'm not sure, but the server error log has it showing up constantly. I imagine when someone posts a thread or edits a thread it occurs.

Did you ever have an add-on or currently have one installed that was related to drafts in any way?
The only add-on we have is the resource manager, but we're not actively using it so I doubt it is related to the problem.

I will try the queries you posted and get back to you.
 

Robust

Well-known member
#7
I'm not sure, but the server error log has it showing up constantly. I imagine when someone posts a thread or edits a thread it occurs.
I see. It's usually helpful to know how to reproduce it, but really as Chris said, draft_id is an auto increment primary key. It's just meant to increment. This error would really mean a draft is being saved and the column 'draft_id' is no longer an auto increment one (blame an add-on for it, or something going wrong when creating/importing the table).