Index: branches/5.0.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r12535 -r12715 --- branches/5.0.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 12535) +++ branches/5.0.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 12715) @@ -1,6 +1,6 @@ IsTempTable()) { - $ci_table = $this->Application->GetTempName($ci_table, 'prefix:'.$this->Prefix); + $ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $this->Prefix); } - $keys_hash = Array( - $this->IDField => $this->ID, - '`'.$ci_table.'`.`PrimaryCat`' => 1, - ); + + $primary_category_clause = Array ('`' . $ci_table . '`.`PrimaryCat`' => 1); + + if (!isset($keys_hash)) { + $keys_hash = Array ($this->IDField => $this->ID); + } + + // merge primary category clause in any case to be sure, that + // CategoryId field will always contain primary category of item + $keys_hash = array_merge($keys_hash, $primary_category_clause); } + return parent::GetKeyClause($method, $keys_hash); }