Index: branches/5.2.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r14244 -r14585 --- branches/5.2.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 14244) +++ branches/5.2.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 14585) @@ -1,6 +1,6 @@ useFilenames) { - $this->checkFilename(); - $this->generateFilename(); - } - $ret = parent::Create($force_id, $system_create); if ($ret) { // TODO: move to OnAfterItemCreate method $this->assignPrimaryCategory(); } + return $ret; } @@ -81,9 +76,12 @@ */ function assignPrimaryCategory() { - $primary_category = $this->GetDBField('CategoryId') > 0 ? $this->GetDBField('CategoryId') : $this->Application->GetVar('m_cat_id'); - $this->assignToCategory($primary_category, true); - $this->SetDBField('CategoryId', $primary_category); // set primary category in item object + if ( $this->GetDBField('CategoryId') <= 0 ) { + // set primary category in item object + $this->SetDBField('CategoryId', $this->Application->GetVar('m_cat_id')); + } + + $this->assignToCategory($this->GetDBField('CategoryId'), true); } function Update($id=null, $system_update=false) @@ -105,7 +103,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'); @@ -131,7 +129,6 @@ return $table; } - function checkFilename() { if( !$this->GetDBField('AutomaticFilename') ) @@ -404,7 +401,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); }