From c64b6f0f9e712f0e733d63f6642d792b5fb284f5 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 15 Jun 2021 15:28:43 +0700 Subject: [PATCH 1/4] [ticket/16840] Add PHP 8.1 test PHPBB3-16840 --- .github/setup-webserver.sh | 12 +++--------- .github/workflows/tests.yml | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/setup-webserver.sh b/.github/setup-webserver.sh index 043d3d6d88..9f0c6e53ef 100755 --- a/.github/setup-webserver.sh +++ b/.github/setup-webserver.sh @@ -28,18 +28,12 @@ NGINX_PHP_CONF="$DIR/nginx-php.conf" PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" PHP_FPM_CONF="$DIR/php-fpm.conf" -if [ "$PHP_VERSION" == '8.1' ] +if [ ! -f $PHP_FPM_BIN ] && [ -f "/usr/bin/php-fpm" ] then - if [ -f "/usr/sbin/php-fpm8.0" ] - then - PHP_FPM_BIN="/usr/sbin/php-fpm8.0" - elif [ ! -f $PHP_FPM_BIN ] && [ -f "/usr/bin/php-fpm" ] - then - PHP_FPM_BIN="/usr/bin/php-fpm" - fi + PHP_FPM_BIN="/usr/bin/php-fpm" fi -if [ ! -f $PHP_FPM_BIN ] && [ "$PHP_VERSION" != '8.1' ] +if [ ! -f $PHP_FPM_BIN ] then sudo apt-get install php$PHP_VERSION-fpm php$PHP_VERSION-cli \ php$PHP_VERSION-curl php$PHP_VERSION-xml php$PHP_VERSION-mbstring \ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de5c8dbdb4..f7e83d8ef8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -128,8 +128,8 @@ jobs: db: "mysql:8.0" - php: '8.0' db: "mysql:5.7" - #- php: '8.1' - # db: "mysql:5.7" + - php: '8.1' + db: "mysql:5.7" name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} From cbbe819affd52aaebcbd1b3472f7a3de7af8f5d4 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 7 Aug 2021 11:21:44 +0700 Subject: [PATCH 2/4] [ticket/16840] Add PHP 8.0 / 8.1 builds for Windows tests Also fix Postrges PHP 8.1 related issue. PHPBB3-16840 --- .github/workflows/tests.yml | 6 ++++++ phpBB/phpbb/db/driver/postgres.php | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7e83d8ef8..8634c14afc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -448,6 +448,10 @@ jobs: include: - php: '7.4' db: "postgres" + - php: '8.0' + db: "postgres" + - php: '8.1' + db: "postgres" name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -523,6 +527,8 @@ jobs: Set-ACL -Path "${env:TEMP_DIR}" -ACLObject $acl cd ${env:GITHUB_WORKSPACE}\phpBB php ..\composer.phar install + php ..\composer.phar remove phpunit/dbunit --dev --update-with-dependencies + php ..\composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs cd .. - name: Setup database run: | diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index 7541d1e6b6..3ee4b2b00e 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -207,14 +207,16 @@ class postgres extends \phpbb\db\driver\driver return false; } + $safe_query_id = $this->clean_query_id($this->query_result); + if ($cache && $cache_ttl) { - $this->open_queries[(int) $this->query_result] = $this->query_result; + $this->open_queries[$safe_query_id] = $this->query_result; $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0) { - $this->open_queries[(int) $this->query_result] = $this->query_result; + $this->open_queries[$safe_query_id] = $this->query_result; } } else if ($this->debug_sql_explain) @@ -555,6 +557,15 @@ class postgres extends \phpbb\db\driver\driver */ private function clean_query_id($query_id) { - return is_resource($query_id) ? (int) $query_id : $query_id; + // As of PHP 8.1 PgSQL functions accept/return \PgSQL\* objects instead of "pgsql *" resources + // Attempting to cast object to int will throw error, hence correctly handle all cases + if (is_resource($query_id)) + { + return function_exists('get_resource_id') ? get_resource_id($query_id) : (int) $query_id; + } + else + { + return is_object($query_id) ? spl_object_id($query_id) : $query_id; + } } } From 0b966144f159689a4383940537e7e07df959f51d Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 8 Aug 2021 13:43:27 +0700 Subject: [PATCH 3/4] [ticket/16840] Exclude redundant composer adjustments for master branch PHPBB3-16840 --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8634c14afc..252a17285a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -527,8 +527,6 @@ jobs: Set-ACL -Path "${env:TEMP_DIR}" -ACLObject $acl cd ${env:GITHUB_WORKSPACE}\phpBB php ..\composer.phar install - php ..\composer.phar remove phpunit/dbunit --dev --update-with-dependencies - php ..\composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs cd .. - name: Setup database run: | From ffa4dc0ff3508807b00c20f7d9e22c684f1f3de5 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 8 Aug 2021 14:49:48 +0700 Subject: [PATCH 4/4] [ticket/16840] Fix s9e test helper PHPBB3-16840 --- tests/test_framework/phpbb_test_case_helpers.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 3e28a3271b..71838bd120 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -450,7 +450,18 @@ class phpbb_test_case_helpers // Cache the parser and renderer with a key based on this method's arguments $cache = new \phpbb\cache\driver\file($cache_dir); - $prefix = '_s9e_' . md5(serialize(func_get_args())); + + // Don't serialize unserializable resource/object arguments + // See https://www.php.net/manual/en/function.serialize.php#refsect1-function.serialize-notes + $args = func_get_args(); + foreach ($args as $key => $arg) + { + if (is_resource($arg) || (is_object($arg) && (!is_a($arg, 'Serializable') && !method_exists($arg, '__serialize')))) + { + unset($args[$key]); + } + } + $prefix = '_s9e_' . md5(serialize($args)); $cache_key_parser = $prefix . '_parser'; $cache_key_renderer = $prefix . '_renderer'; $container->set('cache.driver', $cache);