Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 44 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
avatars | |
0.00% |
0 / 44 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
effectively_installed | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
depends_on | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
update_schema | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
revert_schema | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
update_data | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
update_module_auth | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
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 avatars extends \phpbb\db\migration\migration |
17 | { |
18 | public function effectively_installed() |
19 | { |
20 | // Get current avatar type of guest user |
21 | $sql = 'SELECT user_avatar_type |
22 | FROM ' . $this->table_prefix . 'users |
23 | WHERE user_id = ' . ANONYMOUS; |
24 | $result = $this->db->sql_query($sql); |
25 | $backup_type = $this->db->sql_fetchfield('user_avatar_type'); |
26 | $this->db->sql_freeresult($result); |
27 | |
28 | // Try to set avatar type to string |
29 | $sql = 'UPDATE ' . $this->table_prefix . "users |
30 | SET user_avatar_type = 'avatar.driver.upload' |
31 | WHERE user_id = " . ANONYMOUS; |
32 | $this->db->sql_return_on_error(true); |
33 | $effectively_installed = $this->db->sql_query($sql); |
34 | $this->db->sql_return_on_error(); |
35 | |
36 | // Restore avatar type of guest user to previous state |
37 | $sql = 'UPDATE ' . $this->table_prefix . "users |
38 | SET user_avatar_type = '{$backup_type}' |
39 | WHERE user_id = " . ANONYMOUS; |
40 | $this->db->sql_query($sql); |
41 | |
42 | return $effectively_installed !== false; |
43 | } |
44 | |
45 | public static function depends_on() |
46 | { |
47 | return array('\phpbb\db\migration\data\v30x\release_3_0_11'); |
48 | } |
49 | |
50 | public function update_schema() |
51 | { |
52 | return array( |
53 | 'change_columns' => array( |
54 | $this->table_prefix . 'users' => array( |
55 | 'user_avatar_type' => array('VCHAR:255', ''), |
56 | ), |
57 | $this->table_prefix . 'groups' => array( |
58 | 'group_avatar_type' => array('VCHAR:255', ''), |
59 | ), |
60 | ), |
61 | ); |
62 | } |
63 | |
64 | public function revert_schema() |
65 | { |
66 | return array( |
67 | 'change_columns' => array( |
68 | $this->table_prefix . 'users' => array( |
69 | 'user_avatar_type' => array('TINT:2', ''), |
70 | ), |
71 | $this->table_prefix . 'groups' => array( |
72 | 'group_avatar_type' => array('TINT:2', ''), |
73 | ), |
74 | ), |
75 | ); |
76 | } |
77 | |
78 | public function update_data() |
79 | { |
80 | return array( |
81 | array('config.add', array('allow_avatar_gravatar', 0)), |
82 | array('custom', array(array($this, 'update_module_auth'))), |
83 | ); |
84 | } |
85 | |
86 | public function update_module_auth() |
87 | { |
88 | $sql = 'UPDATE ' . $this->table_prefix . "modules |
89 | SET module_auth = 'cfg_allow_avatar' |
90 | WHERE module_class = 'ucp' |
91 | AND module_basename = 'ucp_profile' |
92 | AND module_mode = 'avatar'"; |
93 | $this->db->sql_query($sql); |
94 | } |
95 | } |