The function K2ModelExtraFields::getGroups limits the query to 20 items, if there are more than 20 extrafields groups it does not show all groups correctly. Then a user modifies a category and the extrafield group points to none loosing its value.
How to solve this:
file administrator/components/com_k2/model/extrafields.php
line 227:
function getGroups() {
to
function getGroups($clear = false) {
line 232:
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
to
$limit = ($clear===true)? 0: $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
file administrator/components/com_k2/views/category/view.html.php
line 46:
$groups = $extraFieldsModel->getGroups();
to
$groups = $extraFieldsModel->getGroups(true);
file administrator/components/com_k2/views/extrafields/view.html.php
line 55:
$extraFieldGroups = $model->getGroups();
to
$extraFieldGroups = $model->getGroups(true);
file administrator/components/com_k2/views/extrafield/view.html.php
line 36:
$uniqueGroups= $extraFieldModel->getGroups();
to
$uniqueGroups= $extraFieldModel->getGroups(true);
file administrator/components/com_k2/views/category/view.html.php
line 46:
$groups = $extraFieldsModel->getGroups();
to
$groups = $extraFieldsModel->getGroups(true);
That's all folks!