Index: branches/unlabeled/unlabeled-1.12.10/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r4105 -r4113 --- branches/unlabeled/unlabeled-1.12.10/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4105) +++ branches/unlabeled/unlabeled-1.12.10/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4113) @@ -545,7 +545,7 @@ $value = null; } - $field_name = $this->exportFields[$field_index]; + $field_name = getArrayValue($this->exportFields, $field_index); if ($field_name == 'ResourceId') { return false; } @@ -565,7 +565,7 @@ $this->curItem->CategoryPath = $value ? explode($this->exportOptions['CategorySeparator'], $value) : Array(); } elseif (substr($field_name, 0, 8) == 'Category') { - $this->curItem->CategoryPath[ (int)substr($field_name, 8) ] = $value; + $this->curItem->CategoryPath[ (int)substr($field_name, 8) - 1 ] = $value; } elseif (substr($field_name, 0, 11) == '__VIRTUAL__') { $field_name = substr($field_name, 11); @@ -639,7 +639,9 @@ foreach ($this->curItem->CategoryPath as $category_index => $category_name) { if (!$category_name) continue; - $category_id = $this->getFromCache('category_names', $category_name); + $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); + + $category_id = $this->getFromCache('category_names', $category_key); if ($category_id === false) { // get parent category path to search only in it $current_category_id = $this->Application->GetVar('m_cat_id'); @@ -648,7 +650,7 @@ // get category id from database by name $sql = 'SELECT CategoryId FROM '.TABLE_PREFIX.'Category - WHERE ('.$title_field.' = '.$this->Conn->qstr($category_name).') AND (ParentPath LIKE "'.$parent_path.'%")'; + WHERE ('.$title_field.' = '.$this->Conn->qstr($category_name).') AND (ParentPath LIKE "'.$parent_path.'%") AND (ParentPath <> "'.$parent_path.'")'; $category_id = $this->Conn->GetOne($sql); if ($category_id === false) { @@ -663,11 +665,11 @@ if ($this->dummyCategory->Create($force_id)) { $category_id = $this->dummyCategory->GetID(); $this->addToCache('category_parent_path', $category_id, $this->dummyCategory->GetDBField('ParentPath')); - $this->addToCache('category_names', $category_name, $category_id); + $this->addToCache('category_names', $category_key, $category_id); } } else { - $this->addToCache('category_names', $category_name, $category_id); + $this->addToCache('category_names', $category_key, $category_id); } }