From 51a4349e8bc9a5a255769ee24c57479eb7f350b8 Mon Sep 17 00:00:00 2001 From: William Jacoby Date: Mon, 5 Oct 2026 09:20:38 -0500 Subject: [PATCH] Require phpBB 3.3.19 Refuse to enable on phpBB older than 3.3.19 or below the extension's minimum PHP version, showing a clear reason instead of a generic error. phpBB 3.3.17 through 3.3.19 fixed a series of security issues, so older boards should update phpBB first. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- composer.json | 2 +- ext.php | 32 ++++++++++++++++++++++++- language/en/install_wiki.php | 46 ++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 language/en/install_wiki.php diff --git a/README.md b/README.md index 1be143d..1c15418 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ an active article offline or deleting it entirely: ## Requirements -- phpBB 3.3.0 or later (also tested on phpBB 4.0) +- phpBB 3.3.19 or later (also tested on phpBB 4.0) - PHP 7.4 or later Tested versions and compatibility notes: [docs/compatibility.md](docs/compatibility.md). diff --git a/composer.json b/composer.json index 4b07ec9..da9bb73 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "extra": { "display-name": "phpBB Modders Wiki", "soft-require": { - "phpbb/phpbb": ">=3.3.0,<4.1@dev" + "phpbb/phpbb": ">=3.3.19,<4.1@dev" } } } diff --git a/ext.php b/ext.php index 8e460b0..3cb29b1 100644 --- a/ext.php +++ b/ext.php @@ -51,13 +51,23 @@ class ext extends \phpbb\extension\base const NEW_REPARSER_NAME = 'phpbbmodders.wiki.text_reparser.article_text'; /** + * Refuse to enable below the minimum phpBB and PHP versions. + * * Refuse to enable while the old copy is still enabled; both would run * at once and the old one's data can't be moved while it's in use. * - * @return bool|array True if enableable, otherwise an array of reasons + * @return bool|string|array True if enableable, otherwise a reason string or array of reasons */ public function is_enableable() { + if (!$this->check_phpbb_version() || !$this->check_php_version()) + { + $language = $this->container->get('language'); + $language->add_lang('install_wiki', 'phpbbmodders/wiki'); + + return $language->lang('WIKI_NOT_ENABLEABLE'); + } + if ($this->container->get('ext.manager')->is_enabled(self::OLD_EXT_NAME)) { return ['Disable the old "' . self::OLD_EXT_NAME . '" extension first (keep its data, do not delete it).']; @@ -66,6 +76,26 @@ public function is_enableable() return true; } + /** + * Require phpBB 3.3.19 + * + * @return bool + */ + public function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Require PHP 7.4 + * + * @return bool + */ + public function check_php_version() + { + return PHP_VERSION_ID >= 70400; + } + /** * Move an old install's data to the new name, then enable as usual. * diff --git a/language/en/install_wiki.php b/language/en/install_wiki.php new file mode 100644 index 0000000..71baffc --- /dev/null +++ b/language/en/install_wiki.php @@ -0,0 +1,46 @@ + 'phpBB Modders Wiki could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.', +]);