Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
remove_broken_captcha
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 4
30
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 / 10
0.00% covered (danger)
0.00%
0 / 1
2
 revert_data
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 replace_broken_captcha
0.00% covered (danger)
0.00%
0 / 2
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 remove_broken_captcha extends migration
19{
20    /** @var array List of broken captcha that have been removed  */
21    private array $removed_captchas = [
22        'core.captcha.plugins.gd',
23        'core.captcha.plugins.gd_wave',
24        'core.captcha.plugins.nogd'
25    ];
26
27    public static function depends_on(): array
28    {
29        return [
30            '\phpbb\db\migration\data\v400\dev',
31        ];
32    }
33
34    public function update_data(): array
35    {
36        return [
37            ['config.remove', ['captcha_gd']],
38            ['config.remove', ['captcha_gd_3d_noise']],
39            ['config.remove', ['captcha_gd_fonts']],
40            ['config.remove', ['captcha_gd_foreground_noise']],
41            ['config.remove', ['captcha_gd_wave']],
42            ['config.remove', ['captcha_gd_x_grid']],
43            ['config.remove', ['captcha_gd_y_grid']],
44            ['custom', [[$this, 'replace_broken_captcha']]],
45        ];
46    }
47
48    public function revert_data(): array
49    {
50        return [
51            ['config.add', ['captcha_gd', 0]],
52            ['config.add', ['captcha_gd_3d_noise', 1]],
53            ['config.add', ['captcha_gd_fonts', 1]],
54            ['config.add', ['captcha_gd_foreground_noise', 1]],
55            ['config.add', ['captcha_gd_wave', 0]],
56            ['config.add', ['captcha_gd_x_grid', 25]],
57            ['config.add', ['captcha_gd_y_grid', 25]],
58        ];
59    }
60
61    public function replace_broken_captcha(): void
62    {
63        if (in_array($this->config['captcha_plugin'], $this->removed_captchas))
64        {
65            $this->config->set('captcha_plugin', 'core.captcha.plugins.incomplete');
66        }
67    }
68}