Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php =================================================================== diff -u -N -r5617 -r5618 --- branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5617) +++ branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5618) @@ -237,9 +237,11 @@ if ($event->getEventParam('temp_id') == 0) { $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true)); $object->Load($event->getEventParam('id')); - - $fields_hash = Array('ParentPath' => $object->buildParentPath()); - $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID()); + if ($object->isLoaded()) { + // update path only for real categories (not including "Home" root category) + $fields_hash = Array('ParentPath' => $object->buildParentPath()); + $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID()); + } } } @@ -251,19 +253,23 @@ function OnBeforeDeleteFromLive(&$event) { $id = $event->getEventParam('id'); + + // loding anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event + $temp_object =& $event->getObject( Array('skip_autoload' => true) ); + $temp_object->Load($id); + if ($id == 0) { - // new category -> update chache - $this->Application->StoreVar('PermCache_UpdateRequired', 1); + if ($temp_object->isLoaded()) { + // new category -> update chache (not loaded when "Home" category) + $this->Application->StoreVar('PermCache_UpdateRequired', 1); + } return ; } // existing category was edited, check if in-cache fields are modified - $temp_object =& $event->getObject( Array('skip_autoload' => true) ); - $temp_object->Load($id); - - $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true)); + $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true)); $live_object->Load($id); - + $cached_fields = Array('Name', 'Filename', 'CategoryTemplate', 'ItemTemplate'); foreach ($cached_fields as $cached_field) { @@ -274,15 +280,6 @@ break; } } - - $foreign_keys = $event->getEventParam('foreign_key'); - - // Do not delete live sub-items with 0 id - // otherwise home category permissions got deleted when creating new category - $zero_id = array_search(0, $foreign_keys); - if ($zero_id !== false) { - array_splice($foreign_keys, $zero_id, 1); - } } /** @@ -292,6 +289,11 @@ */ function OnSave(&$event) { + $object =& $event->getObject(); + if ($object->IsRoot()) { + $event->setEventParam('master_ids', Array(0)); + } + parent::OnSave($event); if ($event->status == erSUCCESS && $this->Application->RecallVar('PermCache_UpdateRequired')) { // "catalog" should be in opener stack by now