get_resume_data() public method

Loads resume data from the database
public get_resume_data ( string $name ) : array
$name string Name of the reparser to which the resume data belongs
return array
コード例 #1
0
ファイル: manager_test.php プロジェクト: MrAdder/phpbb
 public function test_get_resume_data()
 {
     $resume_data = array('test_reparser' => array('range-min' => 0, 'range-max' => 100, 'range-size' => 50));
     $this->config_text->set('reparser_resume', serialize($resume_data));
     $this->assert_array_content_equals($resume_data['test_reparser'], $this->reparser_manager->get_resume_data('test_reparser'));
     $this->assertEmpty($this->reparser_manager->get_resume_data('another_reparser'));
 }
コード例 #2
0
ファイル: reparse.php プロジェクト: bantu/phpbb
	/**
	* Reparse all text handled by given reparser within given range
	*
	* @param string $name Reparser name
	*/
	protected function reparse($name)
	{
		$reparser = $this->reparsers[$name];
		$this->resume_data = $this->reparser_manager->get_resume_data($name);
		if ($this->input->getOption('dry-run'))
		{
			$reparser->disable_save();
		}
		else
		{
			$reparser->enable_save();
		}

		// Start at range-max if specified or at the highest ID otherwise
		$max  = $this->get_option('range-max');
		$min  = $this->get_option('range-min');
		$size = $this->get_option('range-size');

		// range-max has no default value, it must be computed for each reparser
		if ($max == null)
		{
			$max = $reparser->get_max_id();
		}

		if ($max < $min)
		{
			return;
		}

		$this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $min, $max));

		$progress = $this->create_progress_bar($max, $this->io, $this->output, true);
		$progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', preg_replace('(^text_reparser\\.)', '', $name)));
		$progress->start();

		// Start from $max and decrement $current by $size until we reach $min
		$current = $max;
		while ($current >= $min)
		{
			$start = max($min, $current + 1 - $size);
			$end   = max($min, $current);

			$progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $start, $end));
			$reparser->reparse_range($start, $end);

			$current = $start - 1;
			$progress->setProgress($max + 1 - $start);

			$this->reparser_manager->update_resume_data($name, $min, $current, $size, !$this->input->getOption('dry-run'));
		}
		$progress->finish();

		$this->io->newLine(2);
	}
コード例 #3
0
ファイル: reparser.php プロジェクト: MrAdder/phpbb
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->reparse_lock->acquire()) {
         if ($this->resume_data === null) {
             $this->resume_data = $this->reparser_manager->get_resume_data($this->reparser_name);
         }
         /**
          * @var \phpbb\textreparser\reparser_interface $reparser
          */
         $reparser = $this->reparsers[$this->reparser_name];
         $min = !empty($this->resume_data['range-min']) ? $this->resume_data['range-min'] : self::MIN;
         $current = !empty($this->resume_data['range-max']) ? $this->resume_data['range-max'] : $reparser->get_max_id();
         $size = !empty($this->resume_data['range-size']) ? $this->resume_data['range-size'] : self::SIZE;
         if ($current >= $min) {
             $start = max($min, $current + 1 - $size);
             $end = max($min, $current);
             $reparser->reparse_range($start, $end);
             $this->reparser_manager->update_resume_data($this->reparser_name, $min, $start - 1, $size);
         }
         $this->config->set($this->reparser_name . '_last_cron', time());
         $this->reparse_lock->release();
     }
 }