1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Advanced BBCode Box |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2018 Matt Friedman |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace vse\abbc3\migrations; |
12
|
|
|
|
13
|
|
|
use phpbb\db\migration\container_aware_migration; |
|
|
|
|
14
|
|
|
|
15
|
|
|
class v322_m10_merge_duplicate_bbcodes extends container_aware_migration |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
|
|
public static function depends_on() |
21
|
|
|
{ |
22
|
|
|
return [ |
23
|
|
|
'\vse\abbc3\migrations\v310_m4_install_data', |
24
|
|
|
'\vse\abbc3\migrations\v310_m5_update_bbcodes', |
25
|
|
|
'\vse\abbc3\migrations\v310_m6_update_bbcodes', |
26
|
|
|
'\vse\abbc3\migrations\v310_m7_update_bbcodes', |
27
|
|
|
'\vse\abbc3\migrations\v322_m8_update_bbcodes', |
28
|
|
|
'\vse\abbc3\migrations\v322_m9_delete_bbcodes', |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public function update_data() |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
|
|
['custom', [[$this, 'update_bbcodes_table']]], |
39
|
|
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Copied from Core migrations |
44
|
|
|
*/ |
45
|
|
|
public function update_bbcodes_table() |
46
|
|
|
{ |
47
|
|
|
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline, bbcode_match, bbcode_tpl FROM ' . BBCODES_TABLE; |
|
|
|
|
48
|
|
|
$result = $this->sql_query($sql); |
49
|
|
|
$bbcodes = []; |
50
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
51
|
|
|
{ |
52
|
|
|
$variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with' : 'without'; |
53
|
|
|
$bbcode_name = strtolower(rtrim($row['bbcode_tag'], '=')); |
54
|
|
|
$bbcodes[$bbcode_name][$variant] = $row; |
55
|
|
|
} |
56
|
|
|
$this->db->sql_freeresult($result); |
57
|
|
|
|
58
|
|
|
foreach ($bbcodes as $bbcode_name => $variants) |
59
|
|
|
{ |
60
|
|
|
if (count($variants) === 2) |
61
|
|
|
{ |
62
|
|
|
$this->merge_bbcodes($variants['without'], $variants['with']); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Copied from Core migrations |
69
|
|
|
*/ |
70
|
|
|
protected function merge_bbcodes(array $without, array $with) |
71
|
|
|
{ |
72
|
|
|
$merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes( |
73
|
|
|
[ |
74
|
|
|
'usage' => $without['bbcode_match'], |
75
|
|
|
'template' => $without['bbcode_tpl'] |
76
|
|
|
], |
77
|
|
|
[ |
78
|
|
|
'usage' => $with['bbcode_match'], |
79
|
|
|
'template' => $with['bbcode_tpl'] |
80
|
|
|
] |
81
|
|
|
); |
82
|
|
|
$bbcode_data = [ |
83
|
|
|
'bbcode_tag' => $without['bbcode_tag'], |
84
|
|
|
'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'], |
85
|
|
|
'bbcode_match' => $merged['usage'], |
86
|
|
|
'bbcode_tpl' => $merged['template'] |
87
|
|
|
]; |
88
|
|
|
|
89
|
|
|
$sql = 'UPDATE ' . BBCODES_TABLE . ' |
|
|
|
|
90
|
|
|
SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . ' |
91
|
|
|
WHERE bbcode_id = ' . (int) $without['bbcode_id']; |
92
|
|
|
$this->sql_query($sql); |
93
|
|
|
|
94
|
|
|
$sql = 'DELETE FROM ' . BBCODES_TABLE . ' |
95
|
|
|
WHERE bbcode_id = ' . (int) $with['bbcode_id']; |
96
|
|
|
$this->sql_query($sql); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths