From 924c8ea74795d6f6bbbae003d38d1d54c03fdb57 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 20 Oct 2021 15:37:36 -0700 Subject: [PATCH 01/14] Update tests --- phpunit.xml.dist | 44 +++++++++++++++++------------------ tests/event/listener_base.php | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 574c6b9..cd8d13a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,27 @@ - - + + + ./ + + + ./language/ + ./migrations/ + ./tests/ + + ./tests @@ -20,15 +31,4 @@ ./tests/functional/ - - - - ./ - - ./language/ - ./migrations/ - ./tests/ - - - diff --git a/tests/event/listener_base.php b/tests/event/listener_base.php index 68853a5..f6b72da 100644 --- a/tests/event/listener_base.php +++ b/tests/event/listener_base.php @@ -64,7 +64,7 @@ protected function setUp(): void protected function set_listener() { $this->listener = $this->getMockBuilder('\phpbb\teamsecurity\event\listener') - ->setMethods(array( + ->onlyMethods(array( 'in_watch_group', 'send_message' )) From fc68fb48181be55c0a13e141a10aa3139016e633 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 20:48:49 +0200 Subject: [PATCH 02/14] Add support for symfony mailer in phpBB 4.x --- composer.json | 5 +++++ composer.lock | 12 ++++++------ config/services.yml | 1 + event/listener.php | 45 +++++++++++++++++++++++++-------------------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index 72d7fc5..ebd9312 100644 --- a/composer.json +++ b/composer.json @@ -27,5 +27,10 @@ "soft-require": { "phpbb/phpbb": ">=3.2.0" } + }, + "config": { + "allow-plugins": { + "composer/installers": true + } } } diff --git a/composer.lock b/composer.lock index 90e17fa..545d048 100644 --- a/composer.lock +++ b/composer.lock @@ -1,11 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "e850460513ee3fc3b5ef50f07ae2122c", - "content-hash": "16d560f796d2f55cacc2ba4181c46e11", + "content-hash": "a053eca997a7f176f50a7b20028a853a", "packages": [ { "name": "composer/installers", @@ -99,7 +98,7 @@ "zend", "zikula" ], - "time": "2015-01-11 03:51:11" + "time": "2015-01-11T03:51:11+00:00" } ], "packages-dev": [], @@ -109,7 +108,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.3" + "php": ">=5.4" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.6.0" } diff --git a/config/services.yml b/config/services.yml index a65569f..62c47cb 100644 --- a/config/services.yml +++ b/config/services.yml @@ -3,6 +3,7 @@ services: class: phpbb\teamsecurity\event\listener arguments: - '@config' + - '@messenger.method.email' - '@language' - '@log' - '@user' diff --git a/event/listener.php b/event/listener.php index 2c6ebc3..22b90ae 100644 --- a/event/listener.php +++ b/event/listener.php @@ -10,6 +10,11 @@ namespace phpbb\teamsecurity\event; +use phpbb\config\config; +use phpbb\language\language; +use phpbb\log\log; +use phpbb\messenger\method\email; +use phpbb\user; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -17,16 +22,19 @@ */ class listener implements EventSubscriberInterface { - /** @var \phpbb\config\config */ + /** @var config */ protected $config; - /** @var \phpbb\language\language */ + /** @var email */ + protected $email_method; + + /** @var language */ protected $language; - /** @var \phpbb\log\log */ + /** @var log */ protected $log; - /** @var \phpbb\user */ + /** @var user */ protected $user; /** @var string phpBB root path */ @@ -38,17 +46,19 @@ class listener implements EventSubscriberInterface /** * Constructor * - * @param \phpbb\config\config $config Config object - * @param \phpbb\language\language $language Language object - * @param \phpbb\log\log $log The phpBB log system - * @param \phpbb\user $user User object + * @param config $config Config object + * @param email $email_method Email method + * @param language $language Language object + * @param log $log The phpBB log system + * @param user $user User object * @param string $phpbb_root_path phpBB root path * @param string $phpEx phpEx * @access public */ - public function __construct(\phpbb\config\config $config, \phpbb\language\language $language, \phpbb\log\log $log, \phpbb\user $user, $phpbb_root_path, $phpEx) + public function __construct(config $config, email $email_method, language $language, log $log, user $user, string $phpbb_root_path, string $phpEx) { $this->config = $config; + $this->email_method = $email_method; $this->language = $language; $this->log = $log; $this->user = $user; @@ -283,16 +293,11 @@ protected function in_watch_group($user_id) */ protected function send_message($message_data, $template, $cc_user = '') { - if (!class_exists('messenger')) - { - include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext; - } - - $messenger = new \messenger(false); - $messenger->template('@phpbb_teamsecurity/' . $template); - $messenger->to(!empty($this->config['sec_contact']) ? $this->config['sec_contact'] : $this->config['board_contact'], $this->config['board_contact_name']); - $messenger->cc($cc_user); - $messenger->assign_vars($message_data); - $messenger->send(); + $this->email_method->set_use_queue(false); + $this->email_method->template('@phpbb_teamsecurity/' . $template); + $this->email_method->to(!empty($this->config['sec_contact']) ? $this->config['sec_contact'] : $this->config['board_contact'], $this->config['board_contact_name']); + $this->email_method->cc($cc_user); + $this->email_method->assign_vars($message_data); + $this->email_method->send(); } } From 27e94152367c4c96f91d32f21cc5d1943e0d9950 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 20:51:06 +0200 Subject: [PATCH 03/14] Soft require phpBB 4.0 dev --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ebd9312..1511a7d 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "extra": { "display-name": "Team Security Measures", "soft-require": { - "phpbb/phpbb": ">=3.2.0" + "phpbb/phpbb": ">=4.0.0-dev" } }, "config": { diff --git a/composer.lock b/composer.lock index 545d048..962e702 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a053eca997a7f176f50a7b20028a853a", + "content-hash": "87193619e8d8682621f7469485dfa1f6", "packages": [ { "name": "composer/installers", From 3a871268a7034feadd19e753274872f21adee1e7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 20:58:11 +0200 Subject: [PATCH 04/14] Update github actions for 4.0 --- .github/workflows/tests.yml | 151 +++++++++++++++++------------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3fe0539..aedc4c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ env: IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0 EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0 EXECUTABLE_FILES: 1 # Run check for executable files? 1 or 0 - PHPBB_BRANCH: 3.3.x # The phpBB branch to run tests on + PHPBB_BRANCH: master # The phpBB branch to run tests on on: push: @@ -21,12 +21,12 @@ on: jobs: # START Basic Checks Job (EPV, code sniffer, images check, etc.) basic-checks: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' - db: "none" + - php: '8.1' + db: 'none' NOTESTS: 1 name: PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -89,44 +89,42 @@ jobs: # START MySQL and MariaDB Job mysql-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' - db: "mariadb:10.1" - - php: '7.2' - db: "mariadb:10.2" - - php: '7.2' - db: "mariadb:10.3" - - php: '7.2' - db: "mariadb:10.4" - - php: '7.2' - db: "mariadb:10.5" - - php: '7.2' - db: "mysql:5.6" - db_alias: "MyISAM Tests" - MYISAM: 1 - - php: '7.2' - db: "mysql:5.6" - - php: '7.2' - db: "mysql:5.7" - - php: '7.3' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:8.0" - - php: '8.0' - db: "mysql:5.7" - - php: '8.1' - db: "mysql:5.7" - - php: '8.2' - db: "mysql:5.7" - - php: '8.3' - db: "mysql:5.7" - - php: '8.4' - db: "mysql:5.7" + - php: '8.1' + db: "mariadb:10.2" + - php: '8.1' + db: "mariadb:10.3" + - php: '8.1' + db: "mariadb:10.4" + - php: '8.1' + db: "mariadb:10.6" + - php: '8.1' + db: "mariadb:10.9" + - php: '8.1' + db: "mariadb:10.10" + - php: '8.1' + db: "mariadb:10.11" + - php: '8.1' + db: "mysql:5.7" + db_alias: "MyISAM Tests" + MYISAM: 1 + - php: '8.1' + db: "mysql:8.1" + - php: '8.2' + db: "mysql:8.0" + - php: '8.2' + db: "mariadb:10.2" + - php: '8.3' + db: "mysql:5.7" + - php: '8.3' + db: "mariadb:10.2" + - php: '8.4' + db: "mysql:8.0" + - php: '8.4' + db: "mariadb:10.3" name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} @@ -209,44 +207,38 @@ jobs: # START PostgreSQL Job postgres-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' - db: "postgres:9.5" - - php: '7.2' - db: "postgres:9.6" - - php: '7.2' - db: "postgres:10" - - php: '7.2' - db: "postgres:11" - - php: '7.2' - db: "postgres:12" - - php: '7.2' - db: "postgres:13" - - php: '7.3' - db: "postgres:13" - - php: '7.4' - db: "postgres:13" - - php: '8.0' - db: "postgres:12" - - php: '8.0' - db: "postgres:13" - - php: '8.1' - db: "postgres:14" - - php: '8.2' - db: "postgres:14" - - php: '8.3' - db: "postgres:14" - - php: '8.4' - db: "postgres:14" + - php: '8.1' + db: "postgres:9.5" + - php: '8.1' + db: "postgres:9.6" + - php: '8.1' + db: "postgres:10" + - php: '8.1' + db: "postgres:11" + - php: '8.1' + db: "postgres:12" + - php: '8.1' + db: "postgres:13" + - php: '8.1' + db: "postgres:14" + - php: '8.1' + db: "postgres:15" + - php: '8.2' + db: "postgres:9.5" + - php: '8.3' + db: "postgres:9.5" + - php: '8.4' + db: "postgres:9.5" name: PHP ${{ matrix.php }} - ${{ matrix.db }} services: postgres: - image: ${{ matrix.db != 'postgres:9.5' && matrix.db != 'postgres:9.6' && matrix.db != 'postgres:10' && matrix.db != 'postgres:11' && matrix.db != 'postgres:12' && matrix.db != 'postgres:13' && 'postgres:10' || matrix.db }} + image: ${{ matrix.db != 'postgres:9.5' && matrix.db != 'postgres:9.6' && matrix.db != 'postgres:10' && matrix.db != 'postgres:11' && matrix.db != 'postgres:12' && matrix.db != 'postgres:13' && matrix.db != 'postgres:14' && matrix.db != 'postgres:15' && 'postgres:10' || matrix.db }} env: POSTGRES_HOST: localhost POSTGRES_USER: postgres @@ -329,20 +321,23 @@ jobs: strategy: matrix: include: - - php: '7.2' - db: "sqlite3" - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2017-latest" - db_alias: 'MSSQL 2017' - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2019-latest" - db_alias: 'MSSQL 2019' + - php: '8.1' + db: "sqlite3" + - php: '8.1' + db: "mcr.microsoft.com/mssql/server:2017-latest" + db_alias: 'MSSQL 2017' + - php: '8.1' + db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04" + db_alias: 'MSSQL 2019' + - php: '8.1' + db: "mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04" + db_alias: 'MSSQL 2022' name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} services: mssql: - image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} + image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && matrix.db != 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} env: SA_PASSWORD: "Pssw0rd_12" ACCEPT_EULA: "y" From 17d7ccdd5a6f3810532991c40e697a23fbd71578 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 2 Apr 2025 12:01:07 -0700 Subject: [PATCH 05/14] Update test environments --- .github/workflows/tests.yml | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3fe0539..25a75cb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -325,7 +325,7 @@ jobs: # START Other Tests Job (SQLite 3 and mssql) other-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 strategy: matrix: include: @@ -335,14 +335,14 @@ jobs: db: "mcr.microsoft.com/mssql/server:2017-latest" db_alias: 'MSSQL 2017' - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2019-latest" + db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04" db_alias: 'MSSQL 2019' name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} services: mssql: - image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} + image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} env: SA_PASSWORD: "Pssw0rd_12" ACCEPT_EULA: "y" @@ -382,7 +382,7 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ] + if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] then db='mssql' else diff --git a/README.md b/README.md index 367246a..365d47c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is the repository for the development of the Team Security extension for phpBB. -[![Build Status](https://github.com/phpbb-extensions/teamsecurity/workflows/Tests/badge.svg)](https://github.com/phpbb-extensions/teamsecurity/actions) +[![Build Status](https://github.com/phpbb-extensions/teamsecurity/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb-extensions/teamsecurity/actions) This extension adds passive security features to phpBB that allow the board's founder to watch for potential attacks against members of privileged groups, such as Administrators and Moderators. From dfe61f16e068302ed083ba0d496c797c878f85da Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 21:03:18 +0200 Subject: [PATCH 06/14] Change min php version and run composer update --- composer.json | 6 ++-- composer.lock | 87 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index 1511a7d..a437012 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "phpbb-extension", "description": "Security measures to help watch over team member accounts.", "homepage": "https://www.phpbb.com", - "version": "1.0.0", + "version": "1.1.0-dev", "license": "GPL-2.0-only", "authors": [ { @@ -19,13 +19,13 @@ } ], "require": { - "php": ">=5.4", + "php": ">=8.1", "composer/installers": "~1.0" }, "extra": { "display-name": "Team Security Measures", "soft-require": { - "phpbb/phpbb": ">=4.0.0-dev" + "phpbb/phpbb": ">=4.0.0@dev,<4.1.0@dev" } }, "config": { diff --git a/composer.lock b/composer.lock index 962e702..b4d2285 100644 --- a/composer.lock +++ b/composer.lock @@ -4,40 +4,47 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "87193619e8d8682621f7469485dfa1f6", + "content-hash": "64ffa1585e09458ba10ee672ced8ce36", "packages": [ { "name": "composer/installers", - "version": "v1.0.20", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3" + "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/1bff8aa77a18f3616f468ed8000cf86a5725bac3", - "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3", + "url": "https://api.github.com/repos/composer/installers/zipball/d20a64ed3c94748397ff5973488761b22f6d3f19", + "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19", "shasum": "" }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0" + }, "replace": { "roundcube/plugin-installer": "*", "shama/baton": "*" }, "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" + "composer/composer": "1.6.* || ^2.0", + "composer/semver": "^1 || ^3", + "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan-phpunit": "^0.12.16", + "symfony/phpunit-bridge": "^4.2 || ^5", + "symfony/process": "^2.3" }, - "type": "composer-installer", + "type": "composer-plugin", "extra": { - "class": "Composer\\Installers\\Installer", + "class": "Composer\\Installers\\Plugin", "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "1.x-dev" } }, "autoload": { - "psr-0": { - "Composer\\Installers\\": "src/" + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" } }, "notification-url": "https://packagist.org/downloads/", @@ -52,53 +59,103 @@ } ], "description": "A multi-framework Composer library installer", - "homepage": "http://composer.github.com/installers/", + "homepage": "https://composer.github.io/installers/", "keywords": [ "Craft", "Dolibarr", + "Eliasis", "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", "MODX Evo", + "MantisBT", + "Mautic", + "Maya", "OXID", + "Plentymarkets", + "Porto", + "RadPHP", "SMF", + "Starbug", "Thelia", + "Whmcs", "WolfCMS", "agl", + "aimeos", "annotatecms", + "attogram", "bitrix", "cakephp", "chef", + "cockpit", "codeigniter", "concrete5", "croogo", "dokuwiki", "drupal", + "eZ Platform", "elgg", + "expressionengine", "fuelphp", "grav", "installer", + "itop", "joomla", + "known", "kohana", "laravel", + "lavalite", "lithium", "magento", + "majima", "mako", "mediawiki", + "miaoxing", "modulework", + "modx", "moodle", + "osclass", + "pantheon", "phpbb", "piwik", "ppi", + "processwire", "puppet", + "pxcms", + "reindex", "roundcube", "shopware", "silverstripe", + "sydes", + "sylius", "symfony", + "tastyigniter", "typo3", "wordpress", + "yawik", "zend", "zikula" ], - "time": "2015-01-11T03:51:11+00:00" + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/v1.12.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-09-13T08:19:44+00:00" } ], "packages-dev": [], @@ -108,7 +165,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.4" + "php": ">=8.1" }, "platform-dev": [], "plugin-api-version": "2.6.0" From 5f9f32371c5aeed6b25dda800803ccefddb46754 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 2 Apr 2025 12:07:46 -0700 Subject: [PATCH 07/14] Update tests --- .github/workflows/tests.yml | 107 +++++++++++++++++------------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25a75cb..f9169b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,9 +4,9 @@ env: EXTNAME: phpbb/teamsecurity # Your extension vendor/package name SNIFF: 1 # Run code sniffer on your code? 1 or 0 IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0 - EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0 + EPV: 0 # Run EPV (Extension Pre Validator) on your code? 1 or 0 EXECUTABLE_FILES: 1 # Run check for executable files? 1 or 0 - PHPBB_BRANCH: 3.3.x # The phpBB branch to run tests on + PHPBB_BRANCH: master # The phpBB branch to run tests on on: push: @@ -21,12 +21,12 @@ on: jobs: # START Basic Checks Job (EPV, code sniffer, images check, etc.) basic-checks: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' - db: "none" + - db: 'none' + php: '8.1' NOTESTS: 1 name: PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -48,7 +48,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv coverage: none - name: Setup environment for phpBB @@ -89,44 +89,42 @@ jobs: # START MySQL and MariaDB Job mysql-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' - db: "mariadb:10.1" - - php: '7.2' + - php: '8.1' db: "mariadb:10.2" - - php: '7.2' + - php: '8.1' db: "mariadb:10.3" - - php: '7.2' + - php: '8.1' db: "mariadb:10.4" - - php: '7.2' - db: "mariadb:10.5" - - php: '7.2' - db: "mysql:5.6" + - php: '8.1' + db: "mariadb:10.6" + - php: '8.1' + db: "mariadb:10.9" + - php: '8.1' + db: "mariadb:10.10" + - php: '8.1' + db: "mariadb:10.11" + - php: '8.1' + db: "mysql:5.7" db_alias: "MyISAM Tests" MYISAM: 1 - - php: '7.2' - db: "mysql:5.6" - - php: '7.2' - db: "mysql:5.7" - - php: '7.3' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:8.0" - - php: '8.0' - db: "mysql:5.7" - php: '8.1' - db: "mysql:5.7" + db: "mysql:8.1" - php: '8.2' - db: "mysql:5.7" + db: "mysql:8.0" + - php: '8.2' + db: "mariadb:10.2" - php: '8.3' db: "mysql:5.7" + - php: '8.3' + db: "mariadb:10.2" - php: '8.4' - db: "mysql:5.7" + db: "mysql:8.0" + - php: '8.4' + db: "mariadb:10.3" name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} @@ -209,38 +207,32 @@ jobs: # START PostgreSQL Job postgres-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: include: - - php: '7.2' + - php: '8.1' db: "postgres:9.5" - - php: '7.2' + - php: '8.1' db: "postgres:9.6" - - php: '7.2' + - php: '8.1' db: "postgres:10" - - php: '7.2' + - php: '8.1' db: "postgres:11" - - php: '7.2' - db: "postgres:12" - - php: '7.2' - db: "postgres:13" - - php: '7.3' - db: "postgres:13" - - php: '7.4' - db: "postgres:13" - - php: '8.0' + - php: '8.1' db: "postgres:12" - - php: '8.0' + - php: '8.1' db: "postgres:13" - php: '8.1' db: "postgres:14" + - php: '8.1' + db: "postgres:15" - php: '8.2' - db: "postgres:14" + db: "postgres:9.5" - php: '8.3' - db: "postgres:14" + db: "postgres:9.5" - php: '8.4' - db: "postgres:14" + db: "postgres:9.5" name: PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -294,7 +286,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv, pgsql, pdo, pdo_pgsql coverage: none - name: Setup environment for phpBB @@ -329,20 +321,23 @@ jobs: strategy: matrix: include: - - php: '7.2' + - php: '8.1' db: "sqlite3" - - php: '7.2' + - php: '8.1' db: "mcr.microsoft.com/mssql/server:2017-latest" db_alias: 'MSSQL 2017' - - php: '7.2' + - php: '8.1' db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04" db_alias: 'MSSQL 2019' + - php: '8.1' + db: "mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04" + db_alias: 'MSSQL 2022' name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} services: mssql: - image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} + image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && matrix.db != 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} env: SA_PASSWORD: "Pssw0rd_12" ACCEPT_EULA: "y" @@ -382,7 +377,7 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] + if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' ] then db='mssql' else @@ -394,7 +389,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv, sqlsrv, pdo, pdo_sqlsrv coverage: none - name: Setup environment for phpBB From 5ba9190bb3e3fd9f4e93dcc83f64a65b809c8977 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 21:08:35 +0200 Subject: [PATCH 08/14] Start adding email method as mock to listener --- tests/event/listener_base.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/event/listener_base.php b/tests/event/listener_base.php index 68853a5..c030e58 100644 --- a/tests/event/listener_base.php +++ b/tests/event/listener_base.php @@ -18,6 +18,9 @@ class listener_base extends \phpbb_test_case /** @var \phpbb\config\config */ protected $config; + /** @var hpbb\messenger\method\email */ + protected $email_method; + /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\log\log */ protected $log; @@ -44,6 +47,7 @@ protected function setUp(): void // Load/Mock classes required by the event listener class $this->config = new \phpbb\config\config(array('default_dateformat' => 'D M d, Y H:i:s A')); + $this->email_method = $this->getMockBuilder('\phpbb\messenger\method\email')->disableOriginalConstructor()->getMock(); $this->log = $this->getMockBuilder('\phpbb\log\log') ->disableOriginalConstructor() ->getMock(); @@ -70,6 +74,7 @@ protected function set_listener() )) ->setConstructorArgs(array( $this->config, + $this->email_method, $this->lang, $this->log, $this->user, From 1b018557522c362bcfca70c19742b5b69e83f010 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 21:16:33 +0200 Subject: [PATCH 09/14] Pass doctrine_db to tools factory get() --- tests/ext_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ext_test.php b/tests/ext_test.php index 370c3ec..5cf73a9 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -58,8 +58,9 @@ protected function create_extension_manager() $config = new \phpbb\config\config(['version' => PHPBB_VERSION]); $db = $this->new_dbal(); $phpbb_dispatcher = new \phpbb_mock_event_dispatcher(); + $doctrine_db = $this->new_doctrine_dbal(); $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($db); + $db_tools = $factory->get($doctrine_db); $table_prefix = 'phpbb_'; $container = new \phpbb_mock_container_builder(); From f608cb2c65126cd607d699ed327405f5f20eacf6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 21:22:22 +0200 Subject: [PATCH 10/14] Add missing constructor parameter for db migrator --- tests/ext_test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ext_test.php b/tests/ext_test.php index 5cf73a9..f1ab6f2 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -74,6 +74,7 @@ protected function create_extension_manager() $phpbb_root_path, $php_ext, $table_prefix, + self::get_core_tables(), [], new \phpbb\db\migration\helper() ); From 311be3865f2b3cefd818f564c6fb050a47048144 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Apr 2025 21:31:33 +0200 Subject: [PATCH 11/14] Fix extension manager arguments in ext_test --- tests/ext_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ext_test.php b/tests/ext_test.php index f1ab6f2..16530f2 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -85,10 +85,9 @@ protected function create_extension_manager() $container, $db, $config, - new \phpbb\filesystem\filesystem(), + $this->createMock('\phpbb\finder\factory'), 'phpbb_ext', $phpbb_root_path, - $php_ext, null ); } From 68f5aea620e99457cd6a3dca55560cbe454a314f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 2 Apr 2025 12:16:11 -0700 Subject: [PATCH 12/14] Fix tests --- tests/ext_test.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/ext_test.php b/tests/ext_test.php index 370c3ec..203ebb8 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -10,10 +10,13 @@ namespace phpbb\teamsecurity\tests; +require_once __DIR__ . '/../ext.php'; + class ext_test extends \phpbb_database_test_case { protected const TEAM_SECURITY = 'phpbb/teamsecurity'; protected $extension_manager; + protected $class_loader; public function getDataSet() { @@ -24,7 +27,6 @@ protected function setUp(): void { parent::setUp(); - $this->db = null; $this->extension_manager = $this->create_extension_manager(); } @@ -53,16 +55,20 @@ public function test_disable() protected function create_extension_manager() { - global $phpbb_root_path, $php_ext; + $phpbb_root_path = __DIR__ . './../../../../'; + $php_ext = 'php'; $config = new \phpbb\config\config(['version' => PHPBB_VERSION]); $db = $this->new_dbal(); + $db_doctrine = $this->new_doctrine_dbal(); $phpbb_dispatcher = new \phpbb_mock_event_dispatcher(); $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($db); + $finder_factory = new \phpbb\finder\factory(null, false, $phpbb_root_path, $php_ext); + $db_tools = $factory->get($db_doctrine); $table_prefix = 'phpbb_'; $container = new \phpbb_mock_container_builder(); + $container->set('event_dispatcher', $phpbb_dispatcher); $migrator = new \phpbb\db\migrator( $container, @@ -73,20 +79,19 @@ protected function create_extension_manager() $phpbb_root_path, $php_ext, $table_prefix, + self::get_core_tables(), [], new \phpbb\db\migration\helper() ); $container->set('migrator', $migrator); - $container->set('dispatcher', $phpbb_dispatcher); return new \phpbb\extension\manager( $container, $db, $config, - new \phpbb\filesystem\filesystem(), + $finder_factory, 'phpbb_ext', $phpbb_root_path, - $php_ext, null ); } From c983f20ea2f03cc4dfc8b17ce37a6f2818680ec2 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 2 Apr 2025 21:05:15 -0700 Subject: [PATCH 13/14] Fix ext_test.php --- tests/ext_test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ext_test.php b/tests/ext_test.php index dd6249a..203ebb8 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -62,7 +62,6 @@ protected function create_extension_manager() $db = $this->new_dbal(); $db_doctrine = $this->new_doctrine_dbal(); $phpbb_dispatcher = new \phpbb_mock_event_dispatcher(); - $doctrine_db = $this->new_doctrine_dbal(); $factory = new \phpbb\db\tools\factory(); $finder_factory = new \phpbb\finder\factory(null, false, $phpbb_root_path, $php_ext); $db_tools = $factory->get($db_doctrine); From 183f2a3654e5f77408e5df2b7884a4111defdb8d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 3 Apr 2025 08:35:56 -0700 Subject: [PATCH 14/14] Remove unused code --- tests/ext_test.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/ext_test.php b/tests/ext_test.php index 203ebb8..12dee45 100644 --- a/tests/ext_test.php +++ b/tests/ext_test.php @@ -10,13 +10,10 @@ namespace phpbb\teamsecurity\tests; -require_once __DIR__ . '/../ext.php'; - class ext_test extends \phpbb_database_test_case { protected const TEAM_SECURITY = 'phpbb/teamsecurity'; protected $extension_manager; - protected $class_loader; public function getDataSet() {