Index: branches/5.0.x/core/install/upgrades.php =================================================================== diff -u -N -r12809 -r12877 --- branches/5.0.x/core/install/upgrades.php (.../upgrades.php) (revision 12809) +++ branches/5.0.x/core/install/upgrades.php (.../upgrades.php) (revision 12877) @@ -1,6 +1,6 @@ -1, // root 'CreatedOn' => time(), 'ResourceId' => $this->Application->NextResourceId(), ); $category_id = $this->Application->findModule('Name', 'Core', 'RootCat'); - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Category', 'CategoryId = ' . $category_id); + + // get all categories, marked as category index + $sql = 'SELECT ParentPath, CategoryId + FROM ' . TABLE_PREFIX . 'Category + WHERE IsIndex = 1'; + $category_indexes = $this->Conn->GetCol($sql, 'CategoryId'); + + foreach ($category_indexes as $category_id => $parent_path) { + $parent_path = explode('|', substr($parent_path, 1, -1)); + + // set symlink to $category_id for each category, marked as container in given category path + $sql = 'SELECT CategoryId + FROM ' . TABLE_PREFIX . 'Category + WHERE CategoryId IN (' . implode(',', $parent_path) . ') AND (IsIndex = 2)'; + $category_containers = $this->Conn->GetCol($sql); + + if ($category_containers) { + $sql = 'UPDATE ' . TABLE_PREFIX . 'Category + SET SymLinkCategoryId = ' . $category_id . ' + WHERE CategoryId IN (' . implode(',', $category_containers) . ')'; + $this->Conn->Query($sql); + } + + } } if ($mode == 'after') {