release_1_3_0_fulltext   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 16
c 4
b 0
f 0
dl 0
loc 47
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A depends_on() 0 3 1
A effectively_installed() 0 3 1
A revert_data() 0 13 1
A revert_fulltext_changes() 0 14 2
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_3_0_fulltext 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_fulltext']);
18
	}
19
20
	public static function depends_on()
21
	{
22
		return array('\vse\similartopics\migrations\release_1_3_0_data');
23
	}
24
25
	public function revert_data()
26
	{
27
		return array(
28
			// Revert the storage engine back to the original setting if it was stored
29
			array('if', array(
30
				!empty($this->config['similar_topics_fulltext']),
31
				array('custom', array(array($this, 'revert_fulltext_changes'))),
32
			)),
33
34
			// Remove the config holding the original storage engine setting if it exists
35
			array('if', array(
36
				isset($this->config['similar_topics_fulltext']),
37
				array('config.remove', array('similar_topics_fulltext')),
38
			)),
39
		);
40
	}
41
42
	/**
43
	 * Drop the FULLTEXT index on phpbb_topics.topic_title
44
	 * Convert phpbb_topics back to the original storage engine
45
	 */
46
	public function revert_fulltext_changes()
47
	{
48
		$fulltext = new \vse\similartopics\core\fulltext_support($this->db);
49
50
		// Drop the FULLTEXT index
51
		if ($fulltext->is_index('topic_title'))
52
		{
53
			$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...
54
			$this->db->sql_query($sql);
55
		}
56
57
		// Revert the storage engine back to its original setting
58
		$sql = 'ALTER TABLE ' . TOPICS_TABLE . ' ENGINE = ' . $this->db->sql_escape(strtoupper($this->config['similar_topics_fulltext']));
59
		$this->db->sql_query($sql);
60
	}
61
}
62