Index: trunk/core/units/categories/categories_tag_processor.php =================================================================== diff -u -r5164 -r5165 --- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5164) +++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5165) @@ -326,47 +326,50 @@ { safeDefine('CACHE_PERM_CHUNK_SIZE', 30); - $force = $this->Application->GetVar('force'); $continue = $this->Application->GetVar('continue'); + $total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category'); + if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) { + // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update + return true; + } + + if ($continue === false) { + // if we don't have to ask, then assume user selected "Yes" in permcache update dialog + $continue = 1; + } + $updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue)); + if ($continue === '0') { // No in dialog + $updater->clearData(); + $this->Application->Redirect($params['destination_template']); + } $ret = false; // don't ask for update - if ($continue !== false) { - if ($continue == 1) { - if ($this->Application->GetVar('ajax')) { - // call from AJAX request => returns percent - $needs_more = true; - while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) { - // until proceeeded in this step category count exceeds category per step limit - $needs_more = $updater->DoTheJob(); - } - - if ($needs_more) { - // still some categories are left for next step - $updater->setData(); - } - else { - $updater->clearData(); - $this->Application->StoreVar('PermCache_UpdateRequired', 0); - $this->Application->Redirect($params['destination_template']); - } - - $ret = $updater->getDonePercent(); - } + if ($continue == 1) { // Initial run + $updater->setData(); + } + if ($continue == 2) { // Continuing + // called from AJAX request => returns percent + $needs_more = true; + while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) { + // until proceeeded in this step category count exceeds category per step limit + $needs_more = $updater->DoTheJob(); } + + if ($needs_more) { + // still some categories are left for next step + $updater->setData(); + } else { - // user selected "No" in perm cache update dialog + // all done -> redirect $updater->clearData(); + $this->Application->StoreVar('PermCache_UpdateRequired', 0); $this->Application->Redirect($params['destination_template']); } + $ret = $updater->getDonePercent(); } - elseif (!$force && ($updater->totalCats > CACHE_PERM_CHUNK_SIZE)) { - // ask before doing anything - $updater->setData(); - $ret = true; - } return $ret; } }