Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
hidpi_smilies
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 depends_on
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 update_data
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 revert_data
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 gif_to_svg_smilies
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
 svg_to_gif_smilies
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
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
14namespace phpbb\db\migration\data\v400;
15
16use phpbb\db\migration\migration;
17
18class hidpi_smilies extends migration
19{
20    private array $default_smilies = [
21        'icon_arrow',
22        'icon_cool',
23        'icon_cry',
24        'icon_e_biggrin',
25        'icon_e_confused',
26        'icon_e_geek',
27        'icon_e_sad',
28        'icon_e_smile',
29        'icon_e_surprised',
30        'icon_e_ugeek',
31        'icon_e_wink',
32        'icon_eek',
33        'icon_evil',
34        'icon_exclaim',
35        'icon_idea',
36        'icon_lol',
37        'icon_mad',
38        'icon_mrgreen',
39        'icon_neutral',
40        'icon_question',
41        'icon_razz',
42        'icon_redface',
43        'icon_rolleyes',
44        'icon_twisted',
45    ];
46
47    public static function depends_on(): array
48    {
49        return [
50            '\phpbb\db\migration\data\v400\dev'
51        ];
52    }
53
54    public function update_data(): array
55    {
56        return [
57            ['custom', [[$this, 'gif_to_svg_smilies']]],
58        ];
59    }
60
61    public function revert_data(): array
62    {
63        return [
64            ['custom', [[$this, 'svg_to_gif_smilies']]],
65        ];
66    }
67
68    public function gif_to_svg_smilies(): void
69    {
70        foreach ($this->default_smilies as $smiley)
71        {
72            $sql = 'UPDATE ' . $this->tables['smilies'] . "
73                SET smiley_url = '" . $this->db->sql_escape($smiley) . ".svg'
74                WHERE smiley_url = '" . $this->db->sql_escape($smiley) . ".gif'";
75            $this->db->sql_query($sql);
76        }
77    }
78
79    public function svg_to_gif_smilies(): void
80    {
81        foreach ($this->default_smilies as $smiley)
82        {
83            $sql = 'UPDATE ' . $this->tables['smilies'] . "
84                SET smiley_url = '" . $this->db->sql_escape($smiley) . ".gif'
85                WHERE smiley_url = '" . $this->db->sql_escape($smiley) . ".svg'";
86            $this->db->sql_query($sql);
87        }
88    }
89}