From a366fd3bb813a9c0a9b04b1f7e64f2805f82745c Mon Sep 17 00:00:00 2001 From: William Jacoby Date: Thu, 22 Oct 2026 11:57:18 -0500 Subject: [PATCH] Require phpBB 3.3.19 and PHP 8.3.36 for extension enablement --- ext.php | 40 +++++++++++++++++++++++---- language/en/requirereason_install.php | 20 ++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 language/en/requirereason_install.php diff --git a/ext.php b/ext.php index b3c1991..3561905 100644 --- a/ext.php +++ b/ext.php @@ -17,15 +17,45 @@ class ext extends \phpbb\extension\base { /** - * Enable extension if phpBB version requirement is met + * Check whether the extension can be enabled. + * The current phpBB and PHP version should meet or + * exceed the minimum version required by this extension: * - * @return bool + * @return bool|array * @access public */ public function is_enableable() { - $config = $this->container->get('config'); - $allowed = (phpbb_version_compare($config['version'], '3.3', '>=')) ? true : false; - return $allowed; + $enableable = $this->check_phpbb_version() && $this->check_php_version(); + + if (!$enableable) + { + $language = $this->container->get('language'); + $language->add_lang('requirereason_install', 'rmcgirr83/requirereason'); + + return $language->lang('REQUIREREASON_NOT_ENABLEABLE'); + } + + return $enableable; + } + + /** + * Require phpBB 3.3.19 due to several security fixes in the phpBB software. + * + * @return bool + */ + protected function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Requires PHP 8.3.36 due to security fixes. + * + * @return bool + */ + protected function check_php_version() + { + return PHP_VERSION_ID >= 80336; } } diff --git a/language/en/requirereason_install.php b/language/en/requirereason_install.php new file mode 100644 index 0000000..e68186e --- /dev/null +++ b/language/en/requirereason_install.php @@ -0,0 +1,20 @@ + 'Require Reason could not be enabled. It requires phpBB 3.3.19 or later and PHP 8.3.36 or later.', +));