| 1 | <?php |
||
| 13 | class release_1_1_0_data extends \phpbb\db\migration\migration |
||
| 14 | { |
||
| 15 | public function effectively_installed() |
||
| 19 | |||
| 20 | static public function depends_on() |
||
| 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() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Add a FULLTEXT index to phpbb_topics.topic_title |
||
| 59 | */ |
||
| 60 | public function add_topic_title_fulltext() |
||
|
1 ignored issue
–
show
|
|||
| 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
|
|||
| 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() |
||
| 96 | } |
||
| 97 |
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.