m3_config_data::update_data()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
*
4
* Auto Groups extension for the phpBB Forum Software package.
5
*
6
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace phpbb\autogroups\migrations\v10x;
12
13
/**
14
 * Migration stage 3: Config data
15
 */
16
class m3_config_data 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...
17
{
18
	/**
19
	 * Assign migration file dependencies for this migration
20
	 *
21
	 * @return array Array of migration files
22
	 * @static
23
	 * @access public
24
	 */
25
	public static function depends_on()
26
	{
27
		return array('\phpbb\autogroups\migrations\v10x\m1_initial_schema');
28
	}
29
30
	/**
31
	 * Add or update data in the database
32
	 *
33
	 * @return array Array of table data
34
	 * @access public
35
	 */
36
	public function update_data()
37
	{
38
		return array(
39
			array('config.add', array('autogroups_default_exempt', $this->get_initial_groups())),
40
		);
41
	}
42
43
	/**
44
	 * Get the group ids of Administrators and Global Moderators
45
	 *
46
	 * @return string Serialized string of group ids
47
	 * @access protected
48
	 */
49
	protected function get_initial_groups()
50
	{
51
		$group_ids = array();
52
53
		$sql = 'SELECT group_id
54
			FROM ' . GROUPS_TABLE . '
0 ignored issues
show
Bug introduced by
The constant phpbb\autogroups\migrations\v10x\GROUPS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
			WHERE ' . $this->db->sql_in_set('group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS'));
56
		$result = $this->db->sql_query($sql);
57
		while ($row = $this->db->sql_fetchrow($result))
58
		{
59
			$group_ids[] = $row['group_id'];
60
		}
61
		$this->db->sql_freeresult($result);
62
63
		return count($group_ids) ? serialize($group_ids) : '';
64
	}
65
}
66