[ticket/17414] Remove install steps for captcha plugins

This should be handled by migrations instead.

PHPBB-17414
This commit is contained in:
Marc Alexander 2024-10-05 17:06:10 +02:00
parent 89bb72c277
commit 8429145241
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
6 changed files with 54 additions and 37 deletions

View file

@ -128,11 +128,9 @@ class acp_captcha
if (isset($captchas['available'][$selected]))
{
$old_captcha = $factory->get_instance($config['captcha_plugin']);
$old_captcha->uninstall();
$old_captcha->garbage_collect();
$config->set('captcha_plugin', $selected);
$new_captcha = $factory->get_instance($config['captcha_plugin']);
$new_captcha->install();
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
}

View file

@ -184,11 +184,6 @@ abstract class captcha_abstract
$this->garbage_collect(0);
}
function install()
{
return;
}
function validate()
{
global $user;

View file

@ -25,8 +25,7 @@ class legacy_wrapper implements plugin_interface
}
/**
* Check if the plugin is available
* @return bool True if the plugin is available, false if not
* {@inheritDoc}
*/
public function is_available(): bool
{
@ -39,9 +38,7 @@ class legacy_wrapper implements plugin_interface
}
/**
* Check if the plugin has a configuration
*
* @return bool True if the plugin has a configuration, false if not
* {@inheritDoc}
*/
public function has_config(): bool
{
@ -54,9 +51,7 @@ class legacy_wrapper implements plugin_interface
}
/**
* Get the name of the plugin, should be language variable
*
* @return string
* {@inheritDoc}
*/
public function get_name(): string
{
@ -69,10 +64,7 @@ class legacy_wrapper implements plugin_interface
}
/**
* Display the captcha for the specified type
*
* @param int $type Type of captcha, should be one of the CONFIRMATION_* constants
* @return void
* {@inheritDoc}
*/
public function init(int $type): void
{
@ -139,4 +131,36 @@ class legacy_wrapper implements plugin_interface
// Ensure this is deemed as too many attempts
return PHP_INT_MAX;
}
/**
* {@inheritDoc}
*/
public function get_demo_template(): string
{
if (method_exists($this->legacy_captcha, 'get_demo_template'))
{
return $this->legacy_captcha->get_demo_template(0);
}
return '';
}
/**
* {@inheritDoc}
*/
public function garbage_collect(int $confirm_type = 0): void
{
if (method_exists($this->legacy_captcha, 'garbage_collect'))
{
$this->legacy_captcha->garbage_collect($confirm_type);
}
}
public function acp_page($id, $module): void
{
if (method_exists($this->legacy_captcha, 'acp_page'))
{
$this->legacy_captcha->acp_page($id, $module);
}
}
}

View file

@ -80,4 +80,21 @@ interface plugin_interface
* @return int Number of attempts
*/
public function get_attempt_count(): int;
/**
* Get template data for demo
*
* @return string Demo template file name
*/
public function get_demo_template(): string;
/**
* Garbage collect captcha plugin
*
* @param int $confirm_type Confirm type to garbage collect, defaults to all (0)
* @return void
*/
public function garbage_collect(int $confirm_type = 0): void;
public function acp_page($id, $module): void;
}

View file

@ -331,13 +331,6 @@ class qa
$this->garbage_collect(0);
}
/**
* API function - set up shop
*/
function install()
{
}
/**
* API function - see what has to be done to validate
*/
@ -597,11 +590,6 @@ class qa
$user->add_lang('acp/board');
$user->add_lang('captcha_qa');
if (!self::is_installed())
{
$this->install();
}
$module->tpl_name = 'captcha_qa_acp';
$module->page_title = 'ACP_VC_SETTINGS';
$form_key = 'acp_captcha';

View file

@ -184,11 +184,6 @@ class recaptcha extends captcha_abstract
$this->garbage_collect(0);
}
function install()
{
return;
}
function validate()
{
if (!parent::validate())