From 72d880c9aaeac7bca4807ac263db9e4070a53fa4 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 4 Jun 2025 08:23:11 -0700 Subject: [PATCH 1/4] Make skeleton compat. with phpbb3 and 4 --- helper/packager.php | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/helper/packager.php b/helper/packager.php index aa29339..b48f7a0 100644 --- a/helper/packager.php +++ b/helper/packager.php @@ -199,20 +199,35 @@ protected function get_template_engine() 'assets_version' => null, ]); - /** @var path_helper $path_helper */ - $path_helper = $this->phpbb_container->get('path_helper'); - /** @var filesystem $filesystem */ - $filesystem = $this->phpbb_container->get('filesystem'); - $environment = new environment( - $config, - $filesystem, - $path_helper, - $this->phpbb_container->getParameter('core.cache_dir'), - $this->phpbb_container->get('ext.manager'), - new loader( - new filesystem() - ) - ); + $container = $this->phpbb_container; + $path_helper = $container->get('path_helper'); + $filesystem = $container->get('filesystem'); + $cache_dir = $container->getParameter('core.cache_dir'); + $ext_manager = $container->get('ext.manager'); + + $is_phpbb_4 = defined('PHPBB_VERSION') && + phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='); + + $args = $is_phpbb_4 + ? [ + $container->get('assets.bag'), + $config, + $filesystem, + $path_helper, + $cache_dir, + $ext_manager, + new loader() + ] + : [ + $config, + $filesystem, + $path_helper, + $cache_dir, + $ext_manager, + new loader(new filesystem()) + ]; + + $environment = new environment(...$args); // Custom filter for use by packager to decode greater/less than symbols $filter = new \Twig\TwigFilter('skeleton_decode', function ($string) { @@ -225,8 +240,8 @@ protected function get_template_engine() $config, new context(), $environment, - $this->phpbb_container->getParameter('core.cache_dir'), - $this->phpbb_container->get('user'), + $cache_dir, + $container->get('user'), [ new skeleton_version_compare() ] From 4931657add348d1ef988f444015df6fbc94bbe49 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 4 Jun 2025 08:37:27 -0700 Subject: [PATCH 2/4] Bump up PHP and phpBB requirements --- composer.json | 6 +++--- ext.php | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 2ffd82d..f9a6451 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "phpbb-extension", "description": "The official phpBB skeleton extension generator.", "homepage": "https://www.phpbb.com/customise/db/official_tool/ext_skeleton/", - "version": "1.1.16", + "version": "1.2.0-dev", "license": "GPL-2.0-only", "authors": [ { @@ -19,7 +19,7 @@ } ], "require": { - "php": ">=5.6", + "php": ">=7.1", "composer/installers": "~1.0", "ext-zip": "*" }, @@ -29,7 +29,7 @@ "extra": { "display-name": "phpBB Skeleton Extension", "soft-require": { - "phpbb/phpbb": ">=3.2.3,<4.0.0@dev" + "phpbb/phpbb": ">=3.3.0,<4.0.0@dev" }, "version-check": { "host": "www.phpbb.com", diff --git a/ext.php b/ext.php index f085e0d..91107d2 100644 --- a/ext.php +++ b/ext.php @@ -15,13 +15,19 @@ class ext extends \phpbb\extension\base { + /** @var string The default value for PHP to use in skeletons */ const DEFAULT_PHP = '7.1.3'; + /** @var string The default value for minimum phpBB to use in skeletons */ const DEFAULT_PHPBB_MIN = '3.3.0'; + /** @var string The default value for maximum phpBB to use in skeletons */ const DEFAULT_PHPBB_MAX = '4.0.0@dev'; - const REQUIRE_PHPBB_MIN = '3.2.3'; + /** @var string The minimum version of phpBB this skeleton extension supports */ + const REQUIRE_PHPBB_MIN = '3.3.0'; + /** @var string The maximum version of phpBB this skeleton extension supports */ const REQUIRE_PHPBB_MAX = '4.0.0-dev'; - const REQUIRE_PHP = 50600; + /** @var string The minimum version of PHP this skeleton extension supports */ + const REQUIRE_PHP = 70100; /** * @var array An array of installation error messages From 379fb8970a5ccbe721abd339f86b150e5b98dd6d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 4 Jun 2025 08:41:25 -0700 Subject: [PATCH 3/4] Fix tests --- helper/packager.php | 1 - tests/helper/packager_test.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/helper/packager.php b/helper/packager.php index b48f7a0..18b6ee0 100644 --- a/helper/packager.php +++ b/helper/packager.php @@ -16,7 +16,6 @@ use phpbb\config\config; use phpbb\di\service_collection; use phpbb\filesystem\filesystem; -use phpbb\path_helper; use phpbb\skeleton\ext; use phpbb\skeleton\template\twig\extension\skeleton_version_compare; use phpbb\template\context; diff --git a/tests/helper/packager_test.php b/tests/helper/packager_test.php index 7ffa987..e005a15 100644 --- a/tests/helper/packager_test.php +++ b/tests/helper/packager_test.php @@ -217,7 +217,7 @@ public function test_get_template_engine_returns_twig_instance() $user ); - $this->container->expects($this->exactly(2)) + $this->container->expects($this->once()) ->method('getParameter') ->with('core.cache_dir') ->willReturn(false); From 1a007abacbd435a18839428b4e6db8ab6a031c2e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 4 Jun 2025 08:49:09 -0700 Subject: [PATCH 4/4] Rename constants --- ext.php | 24 +++++++++--------------- helper/packager.php | 6 +++--- language/en/common.php | 6 +++--- tests/controller/main_test.php | 4 ++-- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/ext.php b/ext.php index 91107d2..a2cdd1c 100644 --- a/ext.php +++ b/ext.php @@ -15,19 +15,13 @@ class ext extends \phpbb\extension\base { - /** @var string The default value for PHP to use in skeletons */ - const DEFAULT_PHP = '7.1.3'; - /** @var string The default value for minimum phpBB to use in skeletons */ - const DEFAULT_PHPBB_MIN = '3.3.0'; - /** @var string The default value for maximum phpBB to use in skeletons */ - const DEFAULT_PHPBB_MAX = '4.0.0@dev'; + public const DEFAULT_SKELETON_PHP = '7.1.3'; + public const DEFAULT_SKELETON_PHPBB_MIN = '3.3.0'; + public const DEFAULT_SKELETON_PHPBB_MAX = '4.0.0@dev'; - /** @var string The minimum version of phpBB this skeleton extension supports */ - const REQUIRE_PHPBB_MIN = '3.3.0'; - /** @var string The maximum version of phpBB this skeleton extension supports */ - const REQUIRE_PHPBB_MAX = '4.0.0-dev'; - /** @var string The minimum version of PHP this skeleton extension supports */ - const REQUIRE_PHP = 70100; + public const MIN_PHPBB_ALLOWED = '3.3.0'; + public const MAX_PHPBB_ALLOWED = '4.0.0-dev'; + public const MIN_PHP_ALLOWED = 70100; /** * @var array An array of installation error messages @@ -57,11 +51,11 @@ public function is_enableable() */ protected function phpbb_requirement($phpBB_version = PHPBB_VERSION) { - if (phpbb_version_compare($phpBB_version, self::REQUIRE_PHPBB_MIN, '<')) + if (phpbb_version_compare($phpBB_version, self::MIN_PHPBB_ALLOWED, '<')) { $this->errors[] = 'PHPBB_VERSION_MIN_ERROR'; } - else if (phpbb_version_compare($phpBB_version, self::REQUIRE_PHPBB_MAX, '>=')) + else if (phpbb_version_compare($phpBB_version, self::MAX_PHPBB_ALLOWED, '>=')) { $this->errors[] = 'PHPBB_VERSION_MAX_ERROR'; } @@ -75,7 +69,7 @@ protected function phpbb_requirement($phpBB_version = PHPBB_VERSION) */ protected function php_requirement($php_version = PHP_VERSION_ID) { - if ($php_version < self::REQUIRE_PHP) + if ($php_version < self::MIN_PHP_ALLOWED) { $this->errors[] = 'PHP_VERSION_ERROR'; } diff --git a/helper/packager.php b/helper/packager.php index 18b6ee0..6186d6d 100644 --- a/helper/packager.php +++ b/helper/packager.php @@ -74,9 +74,9 @@ public function get_composer_dialog_values() 'extension_homepage' => null, ], 'requirements' => [ - 'php_version' => '>=' . ext::DEFAULT_PHP, - 'phpbb_version_min' => '>=' . ext::DEFAULT_PHPBB_MIN, - 'phpbb_version_max' => '<' . ext::DEFAULT_PHPBB_MAX, + 'php_version' => '>=' . ext::DEFAULT_SKELETON_PHP, + 'phpbb_version_min' => '>=' . ext::DEFAULT_SKELETON_PHPBB_MIN, + 'phpbb_version_max' => '<' . ext::DEFAULT_SKELETON_PHPBB_MAX, ], ]; } diff --git a/language/en/common.php b/language/en/common.php index 0f085d8..7b4665e 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -70,13 +70,13 @@ 'SKELETON_QUESTION_PHP_VERSION' => 'Please enter the PHP requirement of the extension', 'SKELETON_QUESTION_PHP_VERSION_UI' => 'PHP requirement of the extension', - 'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: >=' . \phpbb\skeleton\ext::DEFAULT_PHP, + 'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: >=' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHP, 'SKELETON_QUESTION_PHPBB_VERSION_MIN' => 'Please enter the minimum phpBB requirement of the extension', 'SKELETON_QUESTION_PHPBB_VERSION_MIN_UI' => 'Minimum phpBB requirement of the extension', - 'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: >=' . \phpbb\skeleton\ext::DEFAULT_PHPBB_MIN, + 'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: >=' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHPBB_MIN, 'SKELETON_QUESTION_PHPBB_VERSION_MAX' => 'Please enter the maximum phpBB requirement of the extension', 'SKELETON_QUESTION_PHPBB_VERSION_MAX_UI' => 'Maximum phpBB requirement of the extension', - 'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: <' . \phpbb\skeleton\ext::DEFAULT_PHPBB_MAX, + 'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: <' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHPBB_MAX, 'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Create sample PHP event listeners', 'SKELETON_QUESTION_COMPONENT_PHPLISTENER_UI' => 'PHP event listeners', diff --git a/tests/controller/main_test.php b/tests/controller/main_test.php index cb804f8..3a5ab30 100644 --- a/tests/controller/main_test.php +++ b/tests/controller/main_test.php @@ -146,7 +146,7 @@ public function test_handle($status_code, $page_content) ['vendor_name', '', true, \phpbb\request\request_interface::REQUEST, 'foo'], ['author_name', [''], true, \phpbb\request\request_interface::REQUEST, ['bar']], ['extension_version', '1.0.0-dev', true, \phpbb\request\request_interface::REQUEST, '1.0.0-dev'], - ['php_version', '>=' . ext::DEFAULT_PHP, false, \phpbb\request\request_interface::REQUEST, '>=' . ext::DEFAULT_PHP], + ['php_version', '>=' . ext::DEFAULT_SKELETON_PHP, false, \phpbb\request\request_interface::REQUEST, '>=' . ext::DEFAULT_SKELETON_PHP], ['component_phplistener', false, false, \phpbb\request\request_interface::REQUEST, true], ]); @@ -229,7 +229,7 @@ public function test_handle($status_code, $page_content) 'NAME' => 'php_version', 'DESC' => 'SKELETON_QUESTION_PHP_VERSION_UI', 'DESC_EXPLAIN' => 'SKELETON_QUESTION_PHP_VERSION_EXPLAIN', - 'VALUE' => '>=' . ext::DEFAULT_PHP, + 'VALUE' => '>=' . ext::DEFAULT_SKELETON_PHP, ]], ['requirement', [ 'NAME' => 'phpbb_version_min',