From ee69a9b374fe1a56a83390438b51ad3b14f48816 Mon Sep 17 00:00:00 2001 From: William Jacoby Date: Thu, 22 Oct 2026 11:57:05 -0500 Subject: [PATCH] Require phpBB 3.3.19 and PHP 8.3.36 for extension enablement --- ext.php | 44 ++++++++++++++++++++++++++++----- language/en/topfive_install.php | 20 +++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 language/en/topfive_install.php diff --git a/ext.php b/ext.php index bc8f2d3..6874332 100644 --- a/ext.php +++ b/ext.php @@ -16,13 +16,45 @@ class ext extends \phpbb\extension\base { /** - * Enable extension if phpBB version requirement is met - * - * @return bool - */ + * 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|array + * @access public + */ public function is_enableable() { - $config = $this->container->get('config'); - return version_compare($config['version'], '3.3', '>='); + $enableable = $this->check_phpbb_version() && $this->check_php_version(); + + if (!$enableable) + { + $language = $this->container->get('language'); + $language->add_lang('topfive_install', 'rmcgirr83/topfive'); + + return $language->lang('TOPFIVE_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/topfive_install.php b/language/en/topfive_install.php new file mode 100644 index 0000000..d093f2a --- /dev/null +++ b/language/en/topfive_install.php @@ -0,0 +1,20 @@ + 'Top Five Extension could not be enabled. It requires phpBB 3.3.19 or later and PHP 8.3.36 or later.', +));