Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
mysql_fulltext_drop | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
90 | |
0.00% |
0 / 1 |
effectively_installed | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
depends_on | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
update_schema | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
find_indexes_to_drop | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\db\migration\data\v310; |
15 | |
16 | class mysql_fulltext_drop extends \phpbb\db\migration\migration |
17 | { |
18 | protected $indexes; |
19 | |
20 | public function effectively_installed() |
21 | { |
22 | // This migration is irrelevant for all non-MySQL DBMSes. |
23 | if (strpos($this->db->get_sql_layer(), 'mysql') === false) |
24 | { |
25 | return true; |
26 | } |
27 | |
28 | $this->find_indexes_to_drop(); |
29 | return empty($this->indexes); |
30 | } |
31 | |
32 | public static function depends_on() |
33 | { |
34 | return array( |
35 | '\phpbb\db\migration\data\v310\dev', |
36 | ); |
37 | } |
38 | |
39 | public function update_schema() |
40 | { |
41 | if (empty($this->indexes)) |
42 | { |
43 | return array(); |
44 | } |
45 | |
46 | /* |
47 | * Drop FULLTEXT indexes related to MySQL fulltext search. |
48 | * Doing so is equivalent to dropping the search index from the ACP. |
49 | * Possibly time-consuming recreation of the search index (i.e. |
50 | * FULLTEXT indexes) is left as a task to the admin to not |
51 | * unnecessarily stall the upgrade process. The new search index will |
52 | * then require about 40% less table space (also see PHPBB3-11621). |
53 | */ |
54 | return array( |
55 | 'drop_keys' => array( |
56 | $this->table_prefix . 'posts' => $this->indexes, |
57 | ), |
58 | ); |
59 | } |
60 | |
61 | public function find_indexes_to_drop() |
62 | { |
63 | if ($this->indexes !== null) |
64 | { |
65 | return $this->indexes; |
66 | } |
67 | |
68 | $this->indexes = array(); |
69 | $potential_keys = array('post_subject', 'post_text', 'post_content'); |
70 | foreach ($potential_keys as $key) |
71 | { |
72 | if ($this->db_tools->sql_index_exists($this->table_prefix . 'posts', $key)) |
73 | { |
74 | $this->indexes[] = $key; |
75 | } |
76 | } |
77 | |
78 | return $this->indexes; |
79 | } |
80 | } |