release_1_1_0_data   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 28
c 2
b 0
f 1
dl 0
loc 82
rs 10
wmc 11

7 Methods

Rating   Name   Duplication   Size   Complexity  
A update_data() 0 22 1
A revert_data() 0 4 1
A drop_topic_title_fulltext() 0 9 3
A depends_on() 0 3 1
A add_topic_title_fulltext() 0 9 3
A effectively_installed() 0 3 1
A get_fulltext() 0 3 1
1
<?php
2
/**
3
 *
4
 * Precise Similar Topics
5
 *
6
 * @copyright (c) 2013 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\similartopics\migrations;
12
13
class release_1_1_0_data 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
	public function effectively_installed()
16
	{
17
		return isset($this->config['similar_topics']);
18
	}
19
20
	public static function depends_on()
21
	{
22
		return array('\vse\similartopics\migrations\release_1_1_0_schema');
23
	}
24
25
	public function update_data()
26
	{
27
		return array(
28
			// Add configs
29
			array('config.add', array('similar_topics', '0')),
30
			array('config.add', array('similar_topics_limit', '5')),
31
			array('config.add', array('similar_topics_hide', '')),
32
			array('config.add', array('similar_topics_ignore', '')),
33
			array('config.add', array('similar_topics_type', 'y')),
34
			array('config.add', array('similar_topics_time', '365')),
35
			array('config.add', array('similar_topics_version', '1.1.0')),
36
37
			// Add ACP module
38
			array('module.add', array('acp', 'ACP_CAT_DOT_MODS', 'PST_TITLE_ACP')),
39
			array('module.add', array('acp', 'PST_TITLE_ACP',
40
				array(
41
					'module_basename'	=> '\vse\similartopics\acp\similar_topics_module',
42
					'modes'				=> array('settings'),
43
				),
44
			)),
45
46
			array('custom', array(array($this, 'add_topic_title_fulltext'))),
47
		);
48
	}
49
50
	public function revert_data()
51
	{
52
		return array(
53
			array('custom', array(array($this, 'drop_topic_title_fulltext'))),
54
		);
55
	}
56
57
	/**
58
	 * Add a FULLTEXT index to phpbb_topics.topic_title
59
	 */
60
	public function add_topic_title_fulltext()
61
	{
62
		$fulltext = $this->get_fulltext();
63
64
		// FULLTEXT is supported and topic_title IS NOT an index
65
		if ($fulltext->is_supported() && !$fulltext->is_index('topic_title'))
66
		{
67
			$sql = 'ALTER TABLE ' . TOPICS_TABLE . ' ADD FULLTEXT (topic_title)';
0 ignored issues
show
Bug introduced by
The constant vse\similartopics\migrations\TOPICS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
68
			$this->db->sql_query($sql);
69
		}
70
	}
71
72
	/**
73
	 * Drop the FULLTEXT index on phpbb_topics.topic_title
74
	 */
75
	public function drop_topic_title_fulltext()
76
	{
77
		$fulltext = $this->get_fulltext();
78
79
		// FULLTEXT is supported and topic_title IS an index
80
		if ($fulltext->is_supported() && $fulltext->is_index('topic_title'))
81
		{
82
			$sql = 'ALTER TABLE ' . TOPICS_TABLE . ' DROP INDEX topic_title';
0 ignored issues
show
Bug introduced by
The constant vse\similartopics\migrations\TOPICS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
83
			$this->db->sql_query($sql);
84
		}
85
	}
86
87
	/**
88
	 * Get an instance of the fulltext class
89
	 *
90
	 * @return \vse\similartopics\core\fulltext_support
91
	 */
92
	public function get_fulltext()
93
	{
94
		return new \vse\similartopics\core\fulltext_support($this->db);
95
	}
96
}
97