Completed
Push — develop-3.2.x ( 86239d...17b6f9 )
by Matt
05:09 queued 02:36
created

release_1_1_0_data::revert_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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
14
{
15
	public function effectively_installed()
16
	{
17
		return isset($this->config['similar_topics']);
18
	}
19
20
	static public 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()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
	{
62
		$fulltext = $this->get_fulltext();
63
64
		// FULLTEXT is supported and topic_title IS NOT an index
65
		if ($fulltext->is_supported() && !$fulltext->index('topic_title'))
66
		{
67
			$sql = 'ALTER TABLE ' . TOPICS_TABLE . ' ADD FULLTEXT (topic_title)';
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()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
	{
77
		$fulltext = $this->get_fulltext();
78
79
		// FULLTEXT is supported and topic_title IS an index
80
		if ($fulltext->is_supported() && $fulltext->index('topic_title'))
81
		{
82
			$sql = 'ALTER TABLE ' . TOPICS_TABLE . ' DROP INDEX topic_title';
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