Example #1
0
 /**
  * Run the tool
  *
  * @param ProgressHelper|null $progress
  * @return array
  */
 public function run($progress = null)
 {
     if ($this->start == 0) {
         $this->db->sql_query('TRUNCATE ' . $this->topics_posted_table);
     }
     $insert_buffer = new sql_insert_buffer($this->db, $this->topics_posted_table);
     $batch = $this->get_batch();
     $total = $this->get_total();
     foreach ($batch as $row) {
         $insert_buffer->insert(array('topic_id' => (int) $row['topic_id'], 'user_id' => (int) $row['post_user_id'], 'topic_posted' => 1));
         if ($progress) {
             $progress->advance();
         }
     }
     $insert_buffer->flush();
     $next_batch = $this->start + $this->limit;
     if ($next_batch >= $total) {
         return $this->get_result('RESYNC_DOTTED_TOPICS_COMPLETE', $total, false);
     }
     return $this->get_result($this->user->lang('TOOL_PROGRESS_TOTAL', $next_batch, $total), $total, $next_batch);
 }
 /**
  * Insert method rows to DB
  *
  * @param \phpbb\db\sql_insert_buffer $insert_buffer
  * @param string $item_type
  * @param int $item_id
  * @param int $user_id
  * @param string $methods
  */
 protected function add_method_rows(\phpbb\db\sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods)
 {
     $row_base = array('item_type' => $item_type, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, 'notify' => 1);
     foreach ($methods as $method) {
         $row_base['method'] = $method;
         $insert_buffer->insert($row_base);
     }
 }