/** * Run tool * * @param ProgressHelper|null $progress * @return array */ public function run($progress = null) { $total = $this->get_total(); switch ($this->get_step()) { case 'truncate': $this->search_manager->truncate(); $display_message = 'TRUNCATING_SEARCH'; break; case 'contribs': $this->sync->contribs('index', false, $this->start, $this->limit); $display_message = 'INDEXING_CONTRIBS'; break; case 'posts': $this->sync->posts('index', $this->start, $this->limit); $display_message = 'INDEXING_POSTS'; break; case 'faqs': $this->sync->faqs('index', $this->start, $this->limit); $display_message = 'INDEXING_FAQ'; break; } $next_batch = $this->start + $this->limit; if ($total >= $next_batch) { if ($progress) { $progress->advance($this->limit); } return $this->get_result($display_message, $total, $next_batch, $this->get_step()); } $next_step = $this->get_next_step(); $next_batch = $next_step ? 0 : false; return $this->get_result($display_message, $total, $next_batch, $next_step); }
/** * Remove complete category * * @param sync|null $sync If given sync class, category counts are resynchronized * @return null */ public function delete($sync = null) { // This should be the correct diff value each time $diff = 2; // Resync tree $sql = 'UPDATE ' . $this->sql_table . "\n\t\t\tSET right_id = right_id - {$diff}\n\t\t\tWHERE left_id < {$this->right_id} AND right_id > {$this->right_id}"; phpbb::$db->sql_query($sql); $sql = 'UPDATE ' . $this->sql_table . "\n\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\tWHERE left_id > {$this->right_id}"; phpbb::$db->sql_query($sql); // Delete content $sql = 'DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . ' WHERE category_id = ' . $this->category_id; phpbb::$db->sql_query($sql); // Delete self parent::delete(); // Resync counters if ($sync) { $sync->categories('count'); } // Destroy category cache $this->destroy_cache(); }