XF 2.2 Field 'index_criteria' doesn't have a default value in src/XF/Db/AbstractStatement.php at line 230

alternadiv

Well-known member
When creating a media category, I get:

Code:
XF\Db\Exception: MySQL query error [1364]: Field 'index_criteria' doesn't have a default value in src/XF/Db/AbstractStatement.php at line 230
XF\Db\AbstractStatement->getException() in src/XF/Db/Mysqli/Statement.php at line 198
XF\Db\Mysqli\Statement->getException() in src/XF/Db/Mysqli/Statement.php at line 79
XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 96
XF\Db\AbstractAdapter->query() in src/XF/Db/AbstractAdapter.php at line 220
XF\Db\AbstractAdapter->insert() in src/XF/Mvc/Entity/Entity.php at line 1514
XF\Mvc\Entity\Entity->_saveToSource() in src/XF/Mvc/Entity/Entity.php at line 1246
XF\Mvc\Entity\Entity->save() in src/XF/Mvc/FormAction.php at line 71
XF\Mvc\FormAction->XF\Mvc\{closure}() in src/XF/Mvc/FormAction.php at line 189
XF\Mvc\FormAction->run() in src/addons/XFMG/Admin/Controller/Category.php at line 137
XFMG\Admin\Controller\Category->actionSave() in src/XF/Mvc/Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2351
XF\App->run() in src/XF.php at line 517
XF::runApp() in admin.php at line 13

Code:
XF\Db\Exception: MySQL query error [1364]: Field 'index_criteria' doesn't have a default value src/XF/Db/AbstractStatement.php:230
Generated by: Tyler Mar 10, 2022 at 6:00 PM
Stack trace
INSERT  INTO `xf_mg_category` (`title`, `description`, `parent_category_id`, `display_order`, `min_tags`, `category_type`, `allowed_types`, `category_index_limit`, `category_id`, `media_count`, `album_count`, `comment_count`, `field_cache`, `lft`, `rgt`, `depth`, `breadcrumb_data`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1364, 'HY000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1364, 'HY000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1514): XF\Db\AbstractAdapter->insert('xf_mg_category', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1246): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Mvc/FormAction.php(71): XF\Mvc\Entity\Entity->save(true, false)
#7 src/XF/Mvc/FormAction.php(189): XF\Mvc\FormAction->XF\Mvc\{closure}(Object(XF\Mvc\FormAction))
#8 src/addons/XFMG/Admin/Controller/Category.php(137): XF\Mvc\FormAction->run()
#9 src/XF/Mvc/Dispatcher.php(352): XFMG\Admin\Controller\Category->actionSave(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XFMG:Category', 'Save', Object(XF\Mvc\RouteMatch), Object(XFMG\Admin\Controller\Category), NULL)
#11 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFMG\Admin\Controller\Category), NULL)
#12 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#14 src/XF.php(517): XF\App->run()
#15 admin.php(13): XF::runApp('XF\\Admin\\App')
#16 {main}
Request state
array(4) {
  ["url"] => string(42) "/admin.php?media-gallery/categories/0/save"
  ["referrer"] => string(59) "https://tacoma3g.com/admin.php?media-gallery/categories/add"
  ["_GET"] => array(1) {
    ["media-gallery/categories/0/save"] => string(0) ""
  }
  ["_POST"] => array(12) {
    ["_xfToken"] => string(8) "********"
    ["title"] => string(24) "Rig of the Month Winners"
    ["description"] => string(0) ""
    ["parent_category_id"] => string(1) "0"
    ["display_order"] => string(1) "1"
    ["min_tags"] => string(1) "0"
    ["category_type"] => string(5) "album"
    ["allowed_types"] => array(1) {
      [0] => string(5) "image"
    }
    ["mirror_node_ids"] => array(1) {
      [0] => string(0) ""
    }
    ["_xfRequestUri"] => string(39) "/admin.php?media-gallery/categories/add"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
It looks like you might have installed an add-on which adds search engine index criteria to media gallery categories? This would be a bug in that add-on.
 
I used to have SEO & Index Tools by @Nulumia installed but have since uninstalled it.
Most certainly.

As per resource standards rule # 11, Add-ons must
  1. Prefix new columns
  2. Set a default value for new colums or make them nullable
  3. Remove added columns upon uninstall
It seems like you had an Add-on installed that did not adhere to any if those requirements.

To fix the issue you could try
Code:
ALTER TABLE xf_mg_category CHANGE index_criteria index_criteria BLOB NULL
if that field is a blob (I don't know if it is, but if this is meant to be the equivalent for xf_forum.index_criteria it should)
 
Back
Top Bottom