Index: trunk/core/install/upgrades.sql =================================================================== diff -u -N -r8397 -r8555 --- trunk/core/install/upgrades.sql (.../upgrades.sql) (revision 8397) +++ trunk/core/install/upgrades.sql (.../upgrades.sql) (revision 8555) @@ -104,3 +104,11 @@ ); ALTER TABLE Events ADD ReplacementTags TEXT AFTER Event; + + +# ====== v 4.2.0 ==== +ALTER TABLE Category ADD `TreeLeft` BIGINT NOT NULL AFTER `ParentPath` , +ADD `TreeRight` BIGINT NOT NULL AFTER `TreeLeft` ; + +ALTER TABLE Category ADD INDEX ( `TreeLeft` , `TreeRight` ) ; + Index: trunk/core/units/categories/cache_updater.php =================================================================== diff -u -N -r7884 -r8555 --- trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 7884) +++ trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 8555) @@ -239,6 +239,9 @@ $data['item_template'] = ''; $data['children_count'] = 0; $data['system'] = 0; + $data['left'] = 0; + $data['right'] = 2; + $data['debug_title'] = 'ROOT'; $this->Stack->Push($data); } @@ -248,6 +251,7 @@ $data['children_count'] = count($data['children']); $this->QueryPermissions($data); $data['queried'] = 1; + $data['right'] = $data['left']+1; if ($sql = $data['perms']->GetInsertSQL()) { $this->Conn->Query($sql); @@ -259,7 +263,7 @@ // start with first child if we haven't started yet if (!isset($data['current_child'])) $data['current_child'] = 0; - // if we have more children + // if we have more children on CURRENT LEVEL if (isset($data['children'][$data['current_child']])) { if ($this->StrictPath) { while ( isset($data['children'][ $data['current_child'] ]) && !in_array($data['children'][ $data['current_child'] ], $this->StrictPath) ) { @@ -277,20 +281,24 @@ $next_data['current_id'] = $data['children'][ $data['current_child'] ]; //next iteration should process child $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance $next_data['perms']->SetCatId($next_data['current_id']); + $next_data['left'] = $data['right']; $data['current_child']++; $this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child $this->Stack->Push($next_data); //next iteration should process this child return true; } else { - $this->UpdateCachedPath($data); + $this->Stack->Update($data); $prev_data = $this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none) + $data['right'] = $prev_data['right']; + $this->UpdateCachedPath($data); // we are getting here if we finished with current level, so check if it's first level - then bail out. $this->doneCats++; // moved by Kostja from above, seems to fix the prob $has_more = $this->Stack->Count() > 0; if ($has_more) { $next_data = $this->Stack->Get(); + $next_data['right'] = $data['right']+1; $next_data['children_count'] += $data['children_count']; $this->Stack->Update($next_data); } @@ -305,6 +313,8 @@ 'NamedParentPath' => $data['system'] ? $data['file_name'] : implode('/', $data['named_path'] ), 'CachedCategoryTemplate' => $data['category_template'], 'CachedDescendantCatsQty' => $data['children_count'], + 'TreeLeft' => $data['left'], + 'TreeRight' => $data['right'], ); $i = 1; @@ -330,6 +340,7 @@ $data['titles'][$i][] = $record['l'.$i.'_Name'] ? $record['l'.$i.'_Name'] : $record['l'.$this->primaryLanguageId.'_Name']; $i++; } + $data['debug_title'] = $record['l1_Name']; $data['parent_path'][] = $category_id; $data['named_path'][] = preg_replace('/^Content\\//', '', $record['Filename']);