1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/17414] Change incomplete CAPTCHA to extend new base class

PHPBB-17414
This commit is contained in:
Marc Alexander
2024-10-20 10:55:15 +02:00
parent fd994f4742
commit 3b27b65c76
7 changed files with 86 additions and 66 deletions

View File

@@ -246,4 +246,11 @@ abstract class base implements plugin_interface
}
$this->db->sql_freeresult($result);
}
/**
* {@inheritDoc}
*/
public function acp_page(mixed $id, mixed $module): void
{
}
}

View File

@@ -14,25 +14,34 @@
namespace phpbb\captcha\plugins;
use phpbb\config\config;
use phpbb\exception\runtime_exception;
use phpbb\db\driver\driver_interface;
use phpbb\language\language;
use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb\user;
class incomplete extends captcha_abstract
class incomplete extends base
{
/**
* Constructor for incomplete captcha
*
* @param config $config
* @param driver_interface $db
* @param language $language
* @param request_interface $request
* @param template $template
* @param user $user
* @param string $phpbb_root_path
* @param string $phpEx
*/
public function __construct(protected config $config, protected template $template,
protected string $phpbb_root_path, protected string $phpEx)
{}
public function __construct(config $config, driver_interface $db, language $language, request_interface $request,
protected template $template, user $user, protected string $phpbb_root_path, protected string $phpEx)
{
parent::__construct($config, $db, $language, $request, $user);
}
/**
* @return bool True if captcha is available, false if not
* {@inheritDoc}
*/
public function is_available(): bool
{
@@ -40,70 +49,45 @@ class incomplete extends captcha_abstract
}
/**
* Dummy implementation, not supported by this captcha
*
* @throws runtime_exception
* @return void
* {@inheritDoc}
*/
public function get_generator_class(): void
public function has_config(): bool
{
throw new runtime_exception('NO_GENERATOR_CLASS');
return false;
}
/**
* Get CAPTCHA name language variable
*
* @return string Language variable
* {@inheritDoc}
*/
public static function get_name(): string
public function get_name(): string
{
return 'CAPTCHA_INCOMPLETE';
}
/**
* Init CAPTCHA
*
* @param int $type CAPTCHA type
* @return void
* {@inheritDoc}
*/
public function init($type)
public function set_name(string $name): void
{
}
/**
* Execute demo
*
* @return void
* {@inheritDoc}
*/
public function execute_demo()
public function init(confirm_type $type): void
{
}
/**
* Execute CAPTCHA
*
* @return void
* {@inheritDoc}
*/
public function execute()
{
}
/**
* Get template data for demo
*
* @param int|string $id ACP module ID
*
* @return string Demo template file name
*/
public function get_demo_template($id): string
public function get_demo_template(): string
{
return '';
}
/**
* Get template data for CAPTCHA
*
* @return string CAPTCHA template file name
* {@inheritDoc}
*/
public function get_template(): string
{
@@ -118,9 +102,7 @@ class incomplete extends captcha_abstract
}
/**
* Validate CAPTCHA
*
* @return false Incomplete CAPTCHA will never validate
* {@inheritDoc}
*/
public function validate(): bool
{
@@ -128,12 +110,26 @@ class incomplete extends captcha_abstract
}
/**
* Check whether CAPTCHA is solved
*
* @return false Incomplete CAPTCHA will never be solved
* {@inheritDoc}
*/
public function get_error(): string
{
return '';
}
/**
* {@inheritDoc}
*/
public function is_solved(): bool
{
return false;
}
/**
* {@inheritDoc}
*/
public function get_attempt_count(): int
{
return 0;
}
}

View File

@@ -211,7 +211,7 @@ class legacy_wrapper implements plugin_interface
/**
* {@inheritDoc}
*/
public function acp_page($id, $module): void
public function acp_page(mixed $id, mixed $module): void
{
if (method_exists($this->legacy_captcha, 'acp_page'))
{

View File

@@ -122,5 +122,5 @@ interface plugin_interface
* @param mixed $module ACP module name
* @return void
*/
public function acp_page($id, $module): void;
public function acp_page(mixed $id, mixed $module): void;
}

View File

@@ -229,7 +229,7 @@ class turnstile extends base
/**
* {@inheritDoc}
*/
public function acp_page($id, $module): void
public function acp_page(mixed $id, mixed $module): void
{
$captcha_vars = [
'captcha_turnstile_sitekey' => 'CAPTCHA_TURNSTILE_SITEKEY',