Index: core/kernel/db/cat_dbitem.php =================================================================== --- core/kernel/db/cat_dbitem.php (revision 14393) +++ core/kernel/db/cat_dbitem.php (working copy) @@ -59,10 +59,10 @@ function Create($force_id = false, $system_create = false) { // TODO: move to OnBeforeItemCreate method - if ($this->useFilenames) { + /*if ($this->useFilenames) { $this->checkFilename(); $this->generateFilename(); - } + }*/ $ret = parent::Create($force_id, $system_create); @@ -104,7 +104,7 @@ $ret = parent::Update($id, $system_update); if ($ret) { - $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; + $filename = $this->useFilenames ? (string)$this->GetDBField('Filename') : ''; $sql = 'UPDATE '.$this->CategoryItemsTable().' SET Filename = '.$this->Conn->qstr($filename).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); @@ -403,7 +403,7 @@ 'ItemResourceId' => $this->GetField('ResourceId'), 'PrimaryCat' => $is_primary ? 1 : 0, 'ItemPrefix' => $this->Prefix, - 'Filename' => $this->useFilenames ? $this->GetDBField('Filename') : '', // because some prefixes does not use filenames, + 'Filename' => $this->useFilenames ? (string)$this->GetDBField('Filename') : '', // because some prefixes does not use filenames, ); $this->Conn->doInsert($fields_hash, $table); } Index: core/units/categories/categories_item.php =================================================================== --- core/units/categories/categories_item.php (revision 14393) +++ core/units/categories/categories_item.php (working copy) @@ -18,6 +18,9 @@ { function Create($force_id = false, $system_create = false) { + $parent_category = $this->GetDBField('ParentId') > 0 ? $this->GetDBField('ParentId') : $this->Application->GetVar('m_cat_id'); + $this->SetDBField('ParentId', $parent_category); + $this->checkFilename(); $this->generateFilename(); @@ -33,9 +36,6 @@ $this->SetDBField('CreatedById', $this->Application->RecallVar('user_id')); } - $parent_category = $this->GetDBField('ParentId') > 0 ? $this->GetDBField('ParentId') : $this->Application->GetVar('m_cat_id'); - $this->SetDBField('ParentId', $parent_category); - $ret = parent::Create($force_id, $system_create); if ($ret) { @@ -132,7 +132,7 @@ } $unique_clause = '(Filename = %s) AND (ThemeId = ' . $item_theme . ' OR ThemeId = 0)'; - $check_in_parent_cat_only = $item_id ? ' AND ParentId = ' . $this->GetDBField('ParentId') : ''; + $check_in_parent_cat_only = ' AND ParentId = ' . $this->GetDBField('ParentId'); // check temp table $sql_temp = ' SELECT ' . $this->IDField . ' Index: core/units/helpers/filenames_helper.php =================================================================== --- core/units/helpers/filenames_helper.php (revision 14393) +++ core/units/helpers/filenames_helper.php (working copy) @@ -95,7 +95,7 @@ $item_id = !$item_id ? 0 : $item_id; - if ($table == TABLE_PREFIX.'CategoryItems') { + if ( $this->Application->GetLiveName($table) == TABLE_PREFIX.'CategoryItems' ) { $item_categories_cur = $this->Conn->GetCol('SELECT CategoryId FROM '.$table.' WHERE ItemResourceId = '.$item_id); $item_categories_live = $this->Application->IsTempTable($table) ? $this->Conn->GetCol('SELECT CategoryId FROM '.$this->Application->GetLiveName($table).' WHERE ItemResourceId = '.$item_id) : array();