/**
	* Actively merge the set of templates matched by the data object.
	* May be paginated by setting members correctly. Does not error;
	* return value indicates whether more data needs to be processed.
	*
	* @param	vB_Template_Merge_Data	Potential merge candidates
	*
	* @return	bool					True when all templates are processed, false when more remain
	*/
	public function merge_templates(vB_Template_Merge_Data $data)
	{
		$candidates = $data->fetch_merge_candidates();

		$this->merge_start();

		$this->processed_count = 0;

		while ($template = $this->registry->db->fetch_array($candidates))
		{
			$this->processed_count++;

			if (!$data->can_merge_template($template))
			{
				continue;
			}

			$merge = new vB_Text_Merge_Threeway(
				$template['oldmastertext'],
				$template['newmastertext'],
				$template['customtext'],
				$this->show_output
			);
			$merged_text = $merge->get_merged();

			if ($merged_text)
			{
				$this->merge_success($merged_text, $template);
			}
			else
			{
				$this->merge_conflict($template);
			}

			if ($this->break_merge_early())
			{
				return false;
			}
		}

		return true;
	}
 /**
  * Actively merge the set of templates matched by the data object.
  * May be paginated by setting members correctly. Does not error;
  * return value indicates whether more data needs to be processed.
  *
  * @param	vB_Template_Merge_Data	Potential merge candidates
  * @param	array										Output data, in array form
  *
  * @return	bool					True when all templates are processed, false when more remain
  */
 public function merge_templates(vB_Template_Merge_Data $data, &$output)
 {
     $candidates = $data->fetch_merge_candidates();
     $this->merge_start();
     $this->processed_count = 0;
     while ($template = $this->registry->db->fetch_array($candidates)) {
         $this->processed_count++;
         if (!$data->can_merge_template($template)) {
             continue;
         }
         $merge = new vB_Text_Merge_Threeway($template['oldmastertext'], $template['newmastertext'], $template['customtext'], $this->show_output);
         $merged_text = $merge->get_merged();
         if ($merged_text) {
             if ($result = $this->merge_success($merged_text, $template)) {
                 $output[] = $result;
             }
         } else {
             if ($result = $this->merge_conflict($template)) {
                 $output[] = $result;
             }
         }
         if ($this->break_merge_early()) {
             return false;
         }
     }
     // Do we have any template merges remaining?
     $data->start_offset += $this->processed_count;
     $data->batch_size = 1;
     $candidates = $data->fetch_merge_candidates();
     if ($template = $this->registry->db->fetch_array($candidates)) {
         return false;
     }
     return true;
 }