Passed
Push — master ( 92c09e...d67acc )
by Matt
01:34
created

v336_m17_unparse::depends_on()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 *
4
 * Advanced BBCode Box
5
 *
6
 * @copyright (c) 2023 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\abbc3\migrations;
12
13
class v336_m17_unparse extends \phpbb\db\migration\migration
0 ignored issues
show
Bug introduced by
The type phpbb\db\migration\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
	/**
16
	 * {@inheritdoc}
17
	 */
18
	public static function depends_on()
19
	{
20
		return [
21
			'\vse\abbc3\migrations\v322_m11_reparse',
22
		];
23
	}
24
25
	/**
26
	 * We don't need to reparse posts if this is a completely fresh install, so
27
	 * this migration will check for that and if it is totally fresh, it will undo
28
	 * the changes from v322_m11_reparse.
29
	 *
30
	 * {@inheritdoc}
31
	 */
32
	public function effectively_installed()
33
	{
34
		$sql = 'SELECT 1 as no_30
35
			FROM ' . $this->table_prefix . "migrations
36
			WHERE migration_name = '\\\\vse\\\\abbc3\\\\migrations\\\\v310_m1_remove_data'
37
				AND migration_start_time = 0
38
				AND migration_start_time = 0";
39
		$result = $this->db->sql_query_limit($sql, 1);
40
		$no_30 = (bool) $this->db->sql_fetchfield('no_30');
41
		$this->db->sql_freeresult($result);
42
43
		$sql = 'SELECT 1 as fresh_install
44
			FROM ' . $this->table_prefix . 'migrations
45
			WHERE migration_name ' . $this->db->sql_like_expression('\\\\vse\\\\abbc3\\\\migrations\\\\v310' . $this->db->get_any_char()) . '
46
				AND migration_start_time >= ' . (time() - 180) . '
47
				AND migration_start_time <= ' . (time() + 180);
48
		$result = $this->db->sql_query_limit($sql, 1);
49
		$fresh_install = (bool) $this->db->sql_fetchfield('fresh_install');
50
		$this->db->sql_freeresult($result);
51
52
		return !($no_30 && $fresh_install);
53
	}
54
55
	/**
56
	 * {@inheritdoc}
57
	 */
58
	public function update_data()
59
	{
60
		return [
61
			['config.remove', ['abbc3_reparse']],
62
			['if', [
63
				$this->config->offsetExists('text_reparser.pm_text_last_cron') && $this->config->offsetGet('text_reparser.pm_text_last_cron') == 0,
64
				['config.remove', ['text_reparser.pm_text_last_cron']],
65
				['config.remove', ['text_reparser.pm_text_cron_interval']],
66
			]],
67
			['if', [
68
				$this->config->offsetExists('text_reparser.post_text_last_cron') && $this->config->offsetGet('text_reparser.post_text_last_cron') == 0,
69
				['config.remove', ['text_reparser.post_text_last_cron']],
70
				['config.remove', ['text_reparser.post_text_cron_interval']],
71
			]],
72
		];
73
	}
74
}
75