Issues (95)

migrations/v322_m11_reparse.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
*
4
* Advanced BBCode Box
5
*
6
* @copyright (c) 2018 Matt Friedman
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace vse\abbc3\migrations;
12
13
use phpbb\db\migration\container_aware_migration;
0 ignored issues
show
The type phpbb\db\migration\container_aware_migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
class v322_m11_reparse extends container_aware_migration
16
{
17
	/**
18
	 * {@inheritdoc}
19
	 */
20
	public static function depends_on()
21
	{
22
		return array(
23
			'\phpbb\db\migration\data\v320\text_reparser',
24
			'\vse\abbc3\migrations\v310_m4_install_data',
25
			'\vse\abbc3\migrations\v310_m5_update_bbcodes',
26
			'\vse\abbc3\migrations\v310_m6_update_bbcodes',
27
			'\vse\abbc3\migrations\v310_m7_update_bbcodes',
28
			'\vse\abbc3\migrations\v322_m8_update_bbcodes',
29
			'\vse\abbc3\migrations\v322_m9_delete_bbcodes',
30
			'\vse\abbc3\migrations\v322_m10_merge_duplicate_bbcodes',
31
		);
32
	}
33
34
	/**
35
	 * {@inheritdoc}
36
	 */
37
	public function effectively_installed()
38
	{
39
		return $this->config->offsetExists('abbc3_reparse');
40
	}
41
42
	/**
43
	 * {@inheritdoc}
44
	 */
45
	public function update_data()
46
	{
47
		return array(
48
			array('config.add', array('abbc3_reparse', time())),
49
			array('if', array(
50
				!$this->config->offsetExists('text_reparser.pm_text_last_cron'),
51
				array('config.add', array('text_reparser.pm_text_last_cron', 0)),
52
			)),
53
			array('if', array(
54
				!$this->config->offsetExists('text_reparser.pm_text_cron_interval'),
55
				array('config.add', array('text_reparser.pm_text_cron_interval', 10)),
56
			)),
57
			array('if', array(
58
				!$this->config->offsetExists('text_reparser.post_text_last_cron'),
59
				array('config.add', array('text_reparser.post_text_last_cron', 0)),
60
			)),
61
			array('if', array(
62
				!$this->config->offsetExists('text_reparser.post_text_cron_interval'),
63
				array('config.add', array('text_reparser.post_text_cron_interval', 10)),
64
			)),
65
			array('custom', array(array($this, 'reset_reparsers'))),
66
		);
67
	}
68
69
	/**
70
	 * Initialize post/pm reparsers
71
	 */
72
	public function reset_reparsers()
73
	{
74
		/** @var \phpbb\textreparser\manager $reparser_manager */
75
		$reparser_manager = $this->container->get('text_reparser.manager');
76
77
		/** @var \phpbb\di\service_collection $reparsers */
78
		$reparsers = $this->container->get('text_reparser_collection');
79
80
		/**
81
		 * @var string $name
82
		 * @var \phpbb\textreparser\reparser_interface $reparser
83
		 */
84
		foreach ($reparsers as $name => $reparser)
85
		{
86
			if (in_array($name, ['text_reparser.post_text', 'text_reparser.pm_text']))
87
			{
88
				$reparser_manager->update_resume_data($name, 1, $reparser->get_max_id(), 100);
89
			}
90
		}
91
	}
92
}
93