[ticket/12960] Add migration for removing broken captcha

PHPBB3-12960
This commit is contained in:
Marc Alexander 2024-04-18 22:14:52 +02:00
parent 5d11098753
commit 9d51ca3eb7
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -0,0 +1,67 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v400;
use phpbb\db\migration\migration;
class remove_broken_captcha extends migration
{
private $removed_captchas = [
'core.captcha.plugins.gd',
'core.captcha.plugins.gd_wave',
'core.captcha.plugins.nogd'
];
public static function depends_on(): array
{
return [
'\phpbb\db\migration\data\v400\dev',
];
}
public function update_data(): array
{
return [
['config.remove', ['captcha_gd']],
['config.remove', ['captcha_gd_3d_noise']],
['config.remove', ['captcha_gd_fonts']],
['config.remove', ['captcha_gd_foreground_noise']],
['config.remove', ['captcha_gd_wave']],
['config.remove', ['captcha_gd_x_grid']],
['config.remove', ['captcha_gd_y_grid']],
['custom', [[$this, 'replace_broken_captcha']]],
];
}
public function revert_data(): array
{
return [
['config.add', ['captcha_gd', 0]],
['config.add', ['captcha_gd_3d_noise', 1]],
['config.add', ['captcha_gd_fonts', 1]],
['config.add', ['captcha_gd_foreground_noise', 1]],
['config.add', ['captcha_gd_wave', 0]],
['config.add', ['captcha_gd_x_grid', 25]],
['config.add', ['captcha_gd_y_grid', 25]],
];
}
public function replace_broken_captcha(): void
{
if (in_array($this->config['captcha_plugin'], $this->removed_captchas))
{
$this->config->set('captcha_plugin', 'core.captcha.plugins.incomplete');
}
}
}