Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
fix_user_styles | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
depends_on | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
update_data | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
styles_fix | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 |
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\v32x; |
15 | |
16 | class fix_user_styles extends \phpbb\db\migration\migration |
17 | { |
18 | |
19 | public static function depends_on() |
20 | { |
21 | return array( |
22 | '\phpbb\db\migration\data\v320\v320', |
23 | ); |
24 | } |
25 | |
26 | public function update_data() |
27 | { |
28 | return array( |
29 | array('custom', array(array($this, 'styles_fix'))), |
30 | ); |
31 | } |
32 | |
33 | public function styles_fix() |
34 | { |
35 | $default_style = (int) $this->config['default_style']; |
36 | $enabled_styles = array(); |
37 | |
38 | // Get enabled styles |
39 | $sql = 'SELECT style_id |
40 | FROM ' . STYLES_TABLE . ' |
41 | WHERE style_active = 1'; |
42 | $result = $this->db->sql_query($sql); |
43 | while ($row = $this->db->sql_fetchrow($result)) |
44 | { |
45 | $enabled_styles[] = (int) $row['style_id']; |
46 | } |
47 | $this->db->sql_freeresult($result); |
48 | |
49 | // Set the default style to users who have an invalid style |
50 | $this->sql_query('UPDATE ' . USERS_TABLE . ' |
51 | SET user_style = ' . (int) $default_style . ' |
52 | WHERE ' . $this->db->sql_in_set('user_style', $enabled_styles, true)); |
53 | } |
54 | } |