1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Advertisement management. An extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2017 phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\ads\migrations\v20x; |
12
|
|
|
|
13
|
|
|
class m1_hide_ad_for_group extends \phpbb\db\migration\container_aware_migration |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
|
|
public function effectively_installed() |
19
|
|
|
{ |
20
|
|
|
return $this->db_tools->sql_table_exists($this->table_prefix . 'ad_group'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
*/ |
26
|
|
|
public static function depends_on() |
27
|
|
|
{ |
28
|
|
|
return array( |
29
|
|
|
'\phpbb\ads\migrations\v10x\m1_initial_schema', |
30
|
|
|
'\phpbb\ads\migrations\v10x\m4_indexes', |
31
|
|
|
'\phpbb\ads\migrations\v10x\m6_hide_for_group', |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Add the ad_group table |
37
|
|
|
* |
38
|
|
|
* @return array Array of table schema |
39
|
|
|
* @access public |
40
|
|
|
*/ |
41
|
|
|
public function update_schema() |
42
|
|
|
{ |
43
|
|
|
return array( |
44
|
|
|
'add_tables' => array( |
45
|
|
|
$this->table_prefix . 'ad_group' => array( |
46
|
|
|
'COLUMNS' => array( |
47
|
|
|
'ad_id' => array('UINT', 0), |
48
|
|
|
'group_id' => array('UINT', 0), |
49
|
|
|
), |
50
|
|
|
'PRIMARY_KEY' => array('ad_id', 'group_id'), |
51
|
|
|
), |
52
|
|
|
), |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Drop the ad_group table |
58
|
|
|
* |
59
|
|
|
* @return array Array of table schema |
60
|
|
|
* @access public |
61
|
|
|
*/ |
62
|
|
|
public function revert_schema() |
63
|
|
|
{ |
64
|
|
|
return array( |
65
|
|
|
'drop_tables' => array( |
66
|
|
|
$this->table_prefix . 'ad_group', |
67
|
|
|
), |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Remove phpbb_ads_hide_groups config. |
73
|
|
|
* |
74
|
|
|
* @return array Array of data update instructions |
75
|
|
|
*/ |
76
|
|
|
public function update_data() |
77
|
|
|
{ |
78
|
|
|
return array( |
79
|
|
|
array('custom', array(array($this, 'convert_hide_groups'))), |
80
|
|
|
array('config_text.remove', array('phpbb_ads_hide_groups')), |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Convert hide_groups config value into rows in ad_group table |
86
|
|
|
*/ |
87
|
|
|
public function convert_hide_groups() |
88
|
|
|
{ |
89
|
|
|
$sql_ary = array(); |
90
|
|
|
|
91
|
|
|
$hide_groups = json_decode($this->container->get('config_text')->get('phpbb_ads_hide_groups'), true); |
92
|
|
|
$sql = 'SELECT ad_id |
93
|
|
|
FROM ' . $this->table_prefix . 'ads'; |
94
|
|
|
$result = $this->db->sql_query($sql); |
95
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
96
|
|
|
{ |
97
|
|
|
foreach ($hide_groups as $group_id) |
98
|
|
|
{ |
99
|
|
|
$sql_ary[] = array( |
100
|
|
|
'ad_id' => $row['ad_id'], |
101
|
|
|
'group_id' => $group_id, |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
$this->db->sql_multi_insert($this->table_prefix . 'ad_group', $sql_ary); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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