diff --git a/.github/phpunit-oracle-github.xml b/.github/phpunit-oracle-github.xml
new file mode 100644
index 00000000000..11df735ac29
--- /dev/null
+++ b/.github/phpunit-oracle-github.xml
@@ -0,0 +1,41 @@
+
+
+
+
+ ../tests
+ ../tests/functional
+ ../tests/lint_test.php
+
+
+ ../tests/functional
+
+
+
+
+
+ slow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index bd2a5d93cab..66185d102b5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -16,358 +16,448 @@ on:
jobs:
# Basic checks, e.g. parse errors, commit messages, etc.
- basic-checks:
- runs-on: ubuntu-18.04
- strategy:
- matrix:
- include:
- - db: 'none'
- php: '7.2'
- NOTESTS: 1
-
- name: PHP ${{ matrix.php }} - ${{ matrix.db }}
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- with:
- fetch-depth: 100
-
- - name: Setup PHP
- 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
- coverage: none
-
- - name: Get Composer Cache Directory
- id: composer-cache
- env:
- PHP_VERSION: ${{ matrix.php }}
- run: |
- cd phpBB
- echo "::set-output name=dir::$(composer config cache-files-dir)"
- echo "::set-output name=version::${PHP_VERSION%.*}"
- cd ..
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
-
- - name: Setup environment for phpBB
- env:
- DB: ${{ matrix.db }}
- PHP_VERSION: ${{ matrix.php }}
- NOTESTS: '1'
- run: |
- .github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS
-
- - name: Phing sniff
- run: |
- .github/phing-sniff.sh
-
- - name: Check doctum parse errors
- run: |
- .github/check-doctum-parse-errors.sh
-
- - name: Check image ICC profiles
- run: |
- .github/check-image-icc-profiles.sh
-
- - name: Check executable files
- run: |
- .github/check-executable-files.sh ./
-
- - name: Check commit message
- if: github.event_name == 'pull_request'
- run: |
- git fetch origin $GITHUB_BASE_REF &> /dev/null
- git-tools/commit-msg-hook-range.sh $(git rev-parse origin/$GITHUB_BASE_REF)..$GITHUB_SHA
+# basic-checks:
+# runs-on: ubuntu-18.04
+# strategy:
+# matrix:
+# include:
+# - db: 'none'
+# php: '7.2'
+# NOTESTS: 1
+#
+# name: PHP ${{ matrix.php }} - ${{ matrix.db }}
+#
+# steps:
+# - name: Checkout repository
+# uses: actions/checkout@v2
+# with:
+# fetch-depth: 100
+#
+# - name: Setup PHP
+# 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
+# coverage: none
+#
+# - name: Get Composer Cache Directory
+# id: composer-cache
+# env:
+# PHP_VERSION: ${{ matrix.php }}
+# run: |
+# cd phpBB
+# echo "::set-output name=dir::$(composer config cache-files-dir)"
+# echo "::set-output name=version::${PHP_VERSION%.*}"
+# cd ..
+#
+# - name: Cache Composer dependencies
+# uses: actions/cache@v2
+# with:
+# path: ${{ steps.composer-cache.outputs.dir }}
+# key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
+#
+# - name: Setup environment for phpBB
+# env:
+# DB: ${{ matrix.db }}
+# PHP_VERSION: ${{ matrix.php }}
+# NOTESTS: '1'
+# run: |
+# .github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS
+#
+# - name: Phing sniff
+# run: |
+# .github/phing-sniff.sh
+#
+# - name: Check doctum parse errors
+# run: |
+# .github/check-doctum-parse-errors.sh
+#
+# - name: Check image ICC profiles
+# run: |
+# .github/check-image-icc-profiles.sh
+#
+# - name: Check executable files
+# run: |
+# .github/check-executable-files.sh ./
+#
+# - name: Check commit message
+# if: github.event_name == 'pull_request'
+# run: |
+# git fetch origin $GITHUB_BASE_REF &> /dev/null
+# git-tools/commit-msg-hook-range.sh $(git rev-parse origin/$GITHUB_BASE_REF)..$GITHUB_SHA
# Tests for MySQL and MariaDB
- mysql-tests:
- runs-on: ubuntu-18.04
- strategy:
- matrix:
- include:
- - php: '7.1'
- db: "mariadb:10.1"
- - php: '7.1'
- db: "mariadb:10.2"
- - php: '7.1'
- db: "mariadb:10.3"
- - php: '7.1'
- db: "mariadb:10.4"
- - php: '7.1'
- db: "mariadb:10.5"
- - php: '7.1'
- db: "mysql:5.6"
- db_alias: "MySQL Slow Tests"
- SLOWTESTS: 1
- - php: '7.1'
- db: "mysql:5.6"
- db_alias: "MyISAM Tests"
- MYISAM: 1
- - php: '7.1'
- db: "mysql:5.6"
- - php: '7.1'
- db: "mysql:5.7"
- - 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"
-
- name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
-
- services:
- mysql:
- image: ${{ matrix.db }}
- env:
- MYSQL_ALLOW_EMPTY_PASSWORD: yes
- MYSQL_DATABASE: phpbb_tests
- ports:
- - 3306:3306
- options: >-
- --health-cmd="mysqladmin ping"
- --health-interval=10s
- --health-timeout=5s
- --health-retries=3
-
- redis:
- image: redis
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
- ports:
- - 6379:6379
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
-
- - id: database-type
- env:
- MATRIX_DB: ${{ matrix.db }}
- run: |
- db=$(echo "${MATRIX_DB%%:*}")
- echo "::set-output name=db::$db"
-
- - name: Setup PHP
- 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
- coverage: none
-
- - name: Get Composer Cache Directory
- id: composer-cache
- env:
- PHP_VERSION: ${{ matrix.php }}
- run: |
- cd phpBB
- echo "::set-output name=dir::$(composer config cache-files-dir)"
- echo "::set-output name=version::${PHP_VERSION%.*}"
- cd ..
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
-
- - name: Setup environment for phpBB
- env:
- DB: ${{steps.database-type.outputs.db}}
- PHP_VERSION: ${{ matrix.php }}
- NOTESTS: '0'
- run: |
- .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
-
- - name: Setup database
- env:
- DB: ${{steps.database-type.outputs.db}}
- MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }}
- run: |
- .github/setup-database.sh $DB $MYISAM
-
- - name: Setup LDAP
- if: ${{ matrix.SLOWTESTS == 1 }}
- run: |
- .github/setup-ldap.sh
-
- - name: Lint tests
- if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }}
- run: phpBB/vendor/bin/phpunit tests/lint_test.php
-
- - name: Run unit tests
- env:
- DB: ${{steps.database-type.outputs.db}}
- if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }}
- run: |
- phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
-
- - name: Slow tests
- env:
- DB: ${{steps.database-type.outputs.db}}
- if: ${{ matrix.SLOWTESTS == 1 }}
- run: |
- phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --group slow
+# mysql-tests:
+# runs-on: ubuntu-18.04
+# strategy:
+# matrix:
+# include:
+# - php: '7.1'
+# db: "mariadb:10.1"
+# - php: '7.1'
+# db: "mariadb:10.2"
+# - php: '7.1'
+# db: "mariadb:10.3"
+# - php: '7.1'
+# db: "mariadb:10.4"
+# - php: '7.1'
+# db: "mariadb:10.5"
+# - php: '7.1'
+# db: "mysql:5.6"
+# db_alias: "MySQL Slow Tests"
+# SLOWTESTS: 1
+# - php: '7.1'
+# db: "mysql:5.6"
+# db_alias: "MyISAM Tests"
+# MYISAM: 1
+# - php: '7.1'
+# db: "mysql:5.6"
+# - php: '7.1'
+# db: "mysql:5.7"
+# - 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"
+#
+# name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
+#
+# services:
+# mysql:
+# image: ${{ matrix.db }}
+# env:
+# MYSQL_ALLOW_EMPTY_PASSWORD: yes
+# MYSQL_DATABASE: phpbb_tests
+# ports:
+# - 3306:3306
+# options: >-
+# --health-cmd="mysqladmin ping"
+# --health-interval=10s
+# --health-timeout=5s
+# --health-retries=3
+#
+# redis:
+# image: redis
+# options: >-
+# --health-cmd "redis-cli ping"
+# --health-interval 10s
+# --health-timeout 5s
+# --health-retries 5
+# ports:
+# - 6379:6379
+#
+# steps:
+# - name: Checkout repository
+# uses: actions/checkout@v2
+#
+# - id: database-type
+# env:
+# MATRIX_DB: ${{ matrix.db }}
+# run: |
+# db=$(echo "${MATRIX_DB%%:*}")
+# echo "::set-output name=db::$db"
+#
+# - name: Setup PHP
+# 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
+# coverage: none
+#
+# - name: Get Composer Cache Directory
+# id: composer-cache
+# env:
+# PHP_VERSION: ${{ matrix.php }}
+# run: |
+# cd phpBB
+# echo "::set-output name=dir::$(composer config cache-files-dir)"
+# echo "::set-output name=version::${PHP_VERSION%.*}"
+# cd ..
+#
+# - name: Cache Composer dependencies
+# uses: actions/cache@v2
+# with:
+# path: ${{ steps.composer-cache.outputs.dir }}
+# key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
+#
+# - name: Setup environment for phpBB
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# PHP_VERSION: ${{ matrix.php }}
+# NOTESTS: '0'
+# run: |
+# .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
+#
+# - name: Setup database
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }}
+# run: |
+# .github/setup-database.sh $DB $MYISAM
+#
+# - name: Setup LDAP
+# if: ${{ matrix.SLOWTESTS == 1 }}
+# run: |
+# .github/setup-ldap.sh
+#
+# - name: Lint tests
+# if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }}
+# run: phpBB/vendor/bin/phpunit tests/lint_test.php
+#
+# - name: Run unit tests
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }}
+# run: |
+# phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
+#
+# - name: Slow tests
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# if: ${{ matrix.SLOWTESTS == 1 }}
+# run: |
+# phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --group slow
# Tests for PostgreSQL
- postgres-tests:
- runs-on: ubuntu-18.04
- strategy:
- matrix:
- include:
- - php: '7.1'
- db: "postgres:9.5"
- - php: '7.1'
- db: "postgres:9.6"
- - php: '7.1'
- db: "postgres:10"
- - php: '7.1'
- db: "postgres:11"
- - php: '7.1'
- db: "postgres:12"
- - php: '7.1'
- db: "postgres:13"
- - 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"
-
- 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 }}
- env:
- POSTGRES_HOST: localhost
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- ports:
- - 5432:5432
- options: >-
- -v /var/run/postgresql:/var/run/postgresql
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- redis:
- image: redis
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
- ports:
- - 6379:6379
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
-
- - id: database-type
- env:
- MATRIX_DB: ${{ matrix.db }}
- run: |
- db=$(echo "${MATRIX_DB%%:*}")
- echo "::set-output name=db::$db"
-
- - name: Setup PHP
- 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
- coverage: none
-
- - name: Get Composer Cache Directory
- id: composer-cache
- env:
- PHP_VERSION: ${{ matrix.php }}
- run: |
- cd phpBB
- echo "::set-output name=dir::$(composer config cache-files-dir)"
- echo "::set-output name=version::${PHP_VERSION%.*}"
- cd ..
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
-
- - name: Setup environment for phpBB
- env:
- DB: ${{steps.database-type.outputs.db}}
- PHP_VERSION: ${{ matrix.php }}
- NOTESTS: '0'
- run: |
- .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
-
- - name: Setup database
- env:
- DB: ${{steps.database-type.outputs.db}}
- MYISAM: '0'
- run: |
- .github/setup-database.sh $DB $MYISAM
-
- - name: Run unit tests
- env:
- DB: ${{steps.database-type.outputs.db}}
- run: |
- phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
+# postgres-tests:
+# runs-on: ubuntu-18.04
+# strategy:
+# matrix:
+# include:
+# - php: '7.1'
+# db: "postgres:9.5"
+# - php: '7.1'
+# db: "postgres:9.6"
+# - php: '7.1'
+# db: "postgres:10"
+# - php: '7.1'
+# db: "postgres:11"
+# - php: '7.1'
+# db: "postgres:12"
+# - php: '7.1'
+# db: "postgres:13"
+# - 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"
+#
+# 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 }}
+# env:
+# POSTGRES_HOST: localhost
+# POSTGRES_USER: postgres
+# POSTGRES_PASSWORD: postgres
+# ports:
+# - 5432:5432
+# options: >-
+# -v /var/run/postgresql:/var/run/postgresql
+# --health-cmd pg_isready
+# --health-interval 10s
+# --health-timeout 5s
+# --health-retries 5
+#
+# redis:
+# image: redis
+# options: >-
+# --health-cmd "redis-cli ping"
+# --health-interval 10s
+# --health-timeout 5s
+# --health-retries 5
+# ports:
+# - 6379:6379
+#
+# steps:
+# - name: Checkout repository
+# uses: actions/checkout@v2
+#
+# - id: database-type
+# env:
+# MATRIX_DB: ${{ matrix.db }}
+# run: |
+# db=$(echo "${MATRIX_DB%%:*}")
+# echo "::set-output name=db::$db"
+#
+# - name: Setup PHP
+# 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
+# coverage: none
+#
+# - name: Get Composer Cache Directory
+# id: composer-cache
+# env:
+# PHP_VERSION: ${{ matrix.php }}
+# run: |
+# cd phpBB
+# echo "::set-output name=dir::$(composer config cache-files-dir)"
+# echo "::set-output name=version::${PHP_VERSION%.*}"
+# cd ..
+#
+# - name: Cache Composer dependencies
+# uses: actions/cache@v2
+# with:
+# path: ${{ steps.composer-cache.outputs.dir }}
+# key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
+#
+# - name: Setup environment for phpBB
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# PHP_VERSION: ${{ matrix.php }}
+# NOTESTS: '0'
+# run: |
+# .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
+#
+# - name: Setup database
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# MYISAM: '0'
+# run: |
+# .github/setup-database.sh $DB $MYISAM
+#
+# - name: Run unit tests
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# run: |
+# phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
# Other database types, namely sqlite3 and mssql
- other-tests:
+# other-tests:
+# runs-on: ubuntu-18.04
+# strategy:
+# matrix:
+# include:
+# - php: '7.1'
+# 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'
+#
+# 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 }}
+# env:
+# SA_PASSWORD: "Pssw0rd_12"
+# ACCEPT_EULA: "y"
+# ports:
+# - 1433:1433
+# options: >-
+# --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Pssw0rd_12' -Q \"Use [master]; CREATE DATABASE [phpbb_tests] COLLATE Latin1_General_CI_AS\" || exit 1"
+# --health-interval 10s
+# --health-timeout 5s
+# --health-retries 5
+# --health-start-period 10s
+#
+# redis:
+# image: redis
+# options: >-
+# --health-cmd "redis-cli ping"
+# --health-interval 10s
+# --health-timeout 5s
+# --health-retries 5
+# ports:
+# - 6379:6379
+#
+#
+# steps:
+# - name: Checkout repository
+# uses: actions/checkout@v2
+#
+# - id: database-type
+# 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' ]
+# then
+# db='mssql'
+# else
+# db=$(echo "${MATRIX_DB%%:*}")
+# fi
+# echo "::set-output name=db::$db"
+#
+# - name: Setup PHP
+# 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
+# coverage: none
+#
+# - name: Get Composer Cache Directory
+# id: composer-cache
+# env:
+# PHP_VERSION: ${{ matrix.php }}
+# run: |
+# cd phpBB
+# echo "::set-output name=dir::$(composer config cache-files-dir)"
+# echo "::set-output name=version::${PHP_VERSION%.*}"
+# cd ..
+#
+# - name: Cache Composer dependencies
+# uses: actions/cache@v2
+# with:
+# path: ${{ steps.composer-cache.outputs.dir }}
+# key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
+#
+# - name: Setup environment for phpBB
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# PHP_VERSION: ${{ matrix.php }}
+# NOTESTS: '0'
+# run: |
+# .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
+#
+# - name: Setup database
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# MYISAM: '0'
+# run: |
+# .github/setup-database.sh $DB $MYISAM
+#
+# - name: Run unit tests
+# env:
+# DB: ${{steps.database-type.outputs.db}}
+# run: |
+# phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
+
+ # Oracle tests
+ oracle-test:
runs-on: ubuntu-18.04
strategy:
matrix:
include:
- - php: '7.1'
- 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: '7.1'
+ db: "oracle"
+ #- php: '8.0'
+ # db: "oracle"
- name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
+ name: PHP ${{ matrix.php }} - ${{ 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 }}
- env:
- SA_PASSWORD: "Pssw0rd_12"
- ACCEPT_EULA: "y"
+ oracle:
+ image: "wnameless/oracle-xe-11g-r2"
ports:
- - 1433:1433
- options: >-
- --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Pssw0rd_12' -Q \"Use [master]; CREATE DATABASE [phpbb_tests] COLLATE Latin1_General_CI_AS\" || exit 1"
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
- --health-start-period 10s
+ - 1521:1521
redis:
image: redis
@@ -379,7 +469,6 @@ jobs:
ports:
- 6379:6379
-
steps:
- name: Checkout repository
uses: actions/checkout@v2
@@ -388,19 +477,14 @@ 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' ]
- then
- db='mssql'
- else
- db=$(echo "${MATRIX_DB%%:*}")
- fi
+ db=$(echo "${MATRIX_DB%%:*}")
echo "::set-output name=db::$db"
- name: Setup PHP
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, pdo, oci8, pdo_oci, intl, gd, exif, iconv, ldap
coverage: none
- name: Get Composer Cache Directory
@@ -438,109 +522,110 @@ jobs:
env:
DB: ${{steps.database-type.outputs.db}}
run: |
- phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
+ phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose
+ #--stop-on-error
# Test with IIS & PostgreSQL on Windows
- windows-tests:
- runs-on: windows-2016
- strategy:
- matrix:
- include:
- - php: '7.4'
- db: "postgres"
- - php: '8.0'
- db: "postgres"
- - php: '8.1'
- db: "postgres"
-
- name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }}
-
- steps:
- - name: Prepare git for Windows
- run: |
- git config --system core.autocrlf false
- git config --system core.eol lf
- - name: Checkout repository
- uses: actions/checkout@v2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql
- ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
- coverage: none
-
- - name: Get Composer Cache Directory
- id: composer-cache
- run: |
- cd phpBB
- echo "::set-output name=dir::$(composer config cache-files-dir)"
- $major_version="${{ matrix.php }}".substring(0,1)
- echo "::set-output name=version::$major_version"
- cd ..
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
-
- - name: Setup environment for phpBB
- env:
- GITHUB_WORKSPACE: ${{ github.workspace }}
- TEMP_DIR: ${{ runner.temp }}
- run: |
- Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All
- Set-Service wuauserv -StartupType Manual
- (Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("", "`n`t`n`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
- (Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("`t", "`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
- choco install urlrewrite -y
- Import-Module WebAdministration
- New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB" -Force
- $session = Get-PSSession -Name WinPSCompatSession
- $sb = {Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'}}
- Invoke-Command -Scriptblock $sb -Session $session
- $sb = {Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location "IIS:\Sites\phpBBTest"}
- Invoke-Command -Scriptblock $sb -Session $session
- Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`r`n127.0.0.1`tphpbb.test" -Force
- [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";%windir%\system32\inetsrv")
- echo Setup FAST-CGI configuration
- Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullpath="C:\tools\php\php-cgi.exe"}
- echo Setup FACT-CGI handler
- New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
- iisreset
- NET START W3SVC
- mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\test"
- mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\installer"
- icacls "${env:GITHUB_WORKSPACE}\phpBB\cache" /grant Users:F /T
- icacls "${env:GITHUB_WORKSPACE}\phpBB\files" /grant Users:F /T
- icacls "${env:GITHUB_WORKSPACE}\phpBB\store" /grant Users:F /T
- icacls "${env:GITHUB_WORKSPACE}\phpBB\images\avatars\upload" /grant Users:F /T
- $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
- $acl = Get-ACL "${env:TEMP_DIR}"
- $acl.AddAccessRule($accessRule)
- 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: |
- $postgreSqlSvc = Get-Service "postgresql*"
- Set-Service $postgreSqlSvc.Name -StartupType manual
- $postgreSqlSvc.Start()
- try {
- (Get-Service "postgresql*").Start()
- } catch {
- $_ | select *
- }
- [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}")
- $env:PGPASSWORD = 'root'
- psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres
- psql -c 'create database phpbb_tests;' -U postgres
- Add-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender
- - name: Run unit tests
- run: |
- phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error
+# windows-tests:
+# runs-on: windows-2016
+# strategy:
+# matrix:
+# include:
+# - php: '7.4'
+# db: "postgres"
+# - php: '8.0'
+# db: "postgres"
+# - php: '8.1'
+# db: "postgres"
+#
+# name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }}
+#
+# steps:
+# - name: Prepare git for Windows
+# run: |
+# git config --system core.autocrlf false
+# git config --system core.eol lf
+# - name: Checkout repository
+# uses: actions/checkout@v2
+#
+# - name: Setup PHP
+# uses: shivammathur/setup-php@v2
+# with:
+# php-version: ${{ matrix.php }}
+# extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql
+# ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
+# coverage: none
+#
+# - name: Get Composer Cache Directory
+# id: composer-cache
+# run: |
+# cd phpBB
+# echo "::set-output name=dir::$(composer config cache-files-dir)"
+# $major_version="${{ matrix.php }}".substring(0,1)
+# echo "::set-output name=version::$major_version"
+# cd ..
+#
+# - name: Cache Composer dependencies
+# uses: actions/cache@v2
+# with:
+# path: ${{ steps.composer-cache.outputs.dir }}
+# key: composer-${{ steps.composer-cache.outputs.version }}-${{ hashFiles('phpBB/composer.lock') }}
+#
+# - name: Setup environment for phpBB
+# env:
+# GITHUB_WORKSPACE: ${{ github.workspace }}
+# TEMP_DIR: ${{ runner.temp }}
+# run: |
+# Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All
+# Set-Service wuauserv -StartupType Manual
+# (Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("", "`n`t`n`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
+# (Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("`t", "`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
+# choco install urlrewrite -y
+# Import-Module WebAdministration
+# New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB" -Force
+# $session = Get-PSSession -Name WinPSCompatSession
+# $sb = {Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'}}
+# Invoke-Command -Scriptblock $sb -Session $session
+# $sb = {Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location "IIS:\Sites\phpBBTest"}
+# Invoke-Command -Scriptblock $sb -Session $session
+# Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`r`n127.0.0.1`tphpbb.test" -Force
+# [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";%windir%\system32\inetsrv")
+# echo Setup FAST-CGI configuration
+# Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullpath="C:\tools\php\php-cgi.exe"}
+# echo Setup FACT-CGI handler
+# New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
+# iisreset
+# NET START W3SVC
+# mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\test"
+# mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\installer"
+# icacls "${env:GITHUB_WORKSPACE}\phpBB\cache" /grant Users:F /T
+# icacls "${env:GITHUB_WORKSPACE}\phpBB\files" /grant Users:F /T
+# icacls "${env:GITHUB_WORKSPACE}\phpBB\store" /grant Users:F /T
+# icacls "${env:GITHUB_WORKSPACE}\phpBB\images\avatars\upload" /grant Users:F /T
+# $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
+# $acl = Get-ACL "${env:TEMP_DIR}"
+# $acl.AddAccessRule($accessRule)
+# 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: |
+# $postgreSqlSvc = Get-Service "postgresql*"
+# Set-Service $postgreSqlSvc.Name -StartupType manual
+# $postgreSqlSvc.Start()
+# try {
+# (Get-Service "postgresql*").Start()
+# } catch {
+# $_ | select *
+# }
+# [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}")
+# $env:PGPASSWORD = 'root'
+# psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres
+# psql -c 'create database phpbb_tests;' -U postgres
+# Add-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender
+# - name: Run unit tests
+# run: |
+# phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php
index cd9f1f058ec..7cfbf65fc4b 100644
--- a/phpBB/phpbb/db/driver/driver.php
+++ b/phpBB/phpbb/db/driver/driver.php
@@ -973,6 +973,7 @@ function sql_error($sql = '')
$this->sql_error_sql = $sql;
$this->sql_error_returned = $this->_sql_error();
+ echo "\n" . $this->sql_error_returned['message'] . " $sql\n";
if (!$this->return_on_error)
{
diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php
index 3f6bc49b358..c0374abc149 100644
--- a/phpBB/phpbb/db/driver/oracle.php
+++ b/phpBB/phpbb/db/driver/oracle.php
@@ -160,7 +160,7 @@ function _rewrite_col_compare($args)
*/
function _rewrite_where($where_clause)
{
- preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER);
+ preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[-\d.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[-\d.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER);
$out = '';
foreach ($result as $val)
{
@@ -188,7 +188,7 @@ function _rewrite_where($where_clause)
$in_clause = array();
$sub_exp = substr($val[5], strpos($val[5], '(') + 1, -1);
$extra = false;
- preg_match_all('/\'(?>[^\']++|\'\')*+\'|[\d-.]++/', $sub_exp, $sub_vals, PREG_PATTERN_ORDER);
+ preg_match_all('/\'(?>[^\']++|\'\')*+\'|[-\d.]++/', $sub_exp, $sub_vals, PREG_PATTERN_ORDER);
$i = 0;
foreach ($sub_vals[0] as $sub_val)
{
@@ -282,7 +282,7 @@ function sql_query($query = '', $cache_ttl = 0)
{
$cols = explode(', ', $regs[2]);
- preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
+ preg_match_all('/\'(?:[^\']++|\'\')*+\'|[-\d.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
/* The code inside this comment block breaks clob handling, but does allow the
database restore script to work. If you want to allow no posts longer than 4KB
@@ -353,13 +353,13 @@ function sql_query($query = '', $cache_ttl = 0)
$query = $regs[1] . '(' . $regs[2] . ') VALUES (' . implode(', ', $inserts) . ')';
}
}
- else if (preg_match_all('/^(UPDATE [\\w_]++\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+)\\s+(WHERE.*)$/s', $query, $data, PREG_SET_ORDER))
+ else if (preg_match_all('/^(UPDATE [\\w_]++\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[-\d.]+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[-\d.]+))*+)\\s+(WHERE.*)$/s', $query, $data, PREG_SET_ORDER))
{
if (strlen($data[0][2]) > 4000)
{
$update = $data[0][1];
$where = $data[0][3];
- preg_match_all('/([\\w_]++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[\d-.]++)/', $data[0][2], $temp, PREG_SET_ORDER);
+ preg_match_all('/([\\w_]++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[-\d.]++)/', $data[0][2], $temp, PREG_SET_ORDER);
unset($data);
$cols = array();
@@ -385,7 +385,7 @@ function sql_query($query = '', $cache_ttl = 0)
switch (substr($query, 0, 6))
{
case 'DELETE':
- if (preg_match('/^(DELETE FROM [\w_]++ WHERE)((?:\s*(?:AND|OR)?\s*[\w_]+\s*(?:(?:=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]+)|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))*+)$/', $query, $regs))
+ if (preg_match('/^(DELETE FROM [\w_]++ WHERE)((?:\s*(?:AND|OR)?\s*[\w_]+\s*(?:(?:=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[-\d.]+)|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[-\d.]+,? ?)*+\)))*+)$/', $query, $regs))
{
$query = $regs[1] . $this->_rewrite_where($regs[2]);
unset($regs);
@@ -393,7 +393,7 @@ function sql_query($query = '', $cache_ttl = 0)
break;
case 'UPDATE':
- if (preg_match('/^(UPDATE [\\w_]++\\s+SET [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++)(?:, [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++))*+\\s+WHERE)(.*)$/s', $query, $regs))
+ if (preg_match('/^(UPDATE [\\w_]++\\s+SET [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[-\d.]++|:\w++)(?:, [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[-\d.]++|:\w++))*+\\s+WHERE)(.*)$/s', $query, $regs))
{
$query = $regs[1] . $this->_rewrite_where($regs[2]);
unset($regs);
@@ -401,11 +401,15 @@ function sql_query($query = '', $cache_ttl = 0)
break;
case 'SELECT':
- $query = preg_replace_callback('/([\w_.]++)\s*(?:(=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]++|([\w_.]++))|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]++,? ?)*+\))/', array($this, '_rewrite_col_compare'), $query);
+ $query = preg_replace_callback('/([\w_.]++)\s*(?:(=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[-\d.]++|([\w_.]++))|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[-\d.]++,? ?)*+\))/', array($this, '_rewrite_col_compare'), $query);
break;
}
$this->query_result = @oci_parse($this->db_connect_id, $query);
+ if ($this->query_result === false)
+ {
+ $this->sql_error($query);
+ }
foreach ($array as $key => $value)
{
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index c46bbe11c38..bc5dce9e5f3 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -15,7 +15,8 @@
abstract class phpbb_database_test_case extends TestCase
{
- static private $already_connected;
+ static private $connection = null;
+ static private $connection_manager = null;
private $db_connections;
@@ -265,24 +266,20 @@ public function get_database_config()
public function getConnection()
{
- $config = $this->get_database_config();
-
- $manager = $this->create_connection_manager($config);
-
- if (!self::$already_connected)
+ if (self::$connection !== null)
{
- $manager->recreate_db();
+ return self::$connection;
}
- $manager->connect();
+ $config = $this->get_database_config();
- if (!self::$already_connected)
- {
- $manager->load_schema($this->new_dbal());
- self::$already_connected = true;
- }
+ $manager = $this->create_connection_manager($config);
+
+ $manager->recreate_db();
+ $manager->load_schema($this->new_dbal());
- return $this->createDefaultDBConnection($manager->get_pdo(), 'testdb');
+ self::$connection = $this->createDefaultDBConnection($manager->get_pdo(), 'testdb');
+ return self::$connection;
}
public function new_dbal()
@@ -315,7 +312,13 @@ public function setExpectedTriggerError($errno, $message = '')
protected function create_connection_manager($config)
{
- return new phpbb_database_test_connection_manager($config);
+ if (self::$connection_manager !== null)
+ {
+ return self::$connection_manager;
+ }
+
+ self::$connection_manager = new phpbb_database_test_connection_manager($config);
+ return self::$connection_manager;
}
/** array_diff() does not corretly compare multidimensionsl arrays
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 01c32c32056..5342b2cc1c3 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -32,6 +32,7 @@ public function __construct($config)
{
$this->config = $config;
$this->dbms = $this->get_dbms_data($this->config['dbms']);
+ $this->pdo = null;
}
/**
@@ -51,6 +52,11 @@ public function get_pdo()
*/
public function connect($use_db = true)
{
+ if ($this->pdo !== null)
+ {
+ return;
+ }
+
$dsn = $this->dbms['PDO'] . ':';
switch ($this->dbms['PDO'])
@@ -59,6 +65,15 @@ public function connect($use_db = true)
$dsn .= $this->config['dbhost'];
break;
+ case 'oci':
+ $port = $this->config['dbport'] ? $this->config['dbport'] : 1521;
+ $dsn = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)'
+ . '(HOST=' . $this->config['dbhost'] . ')'
+ . "(PORT=$port))"
+ . '(CONNECT_DATA=(SID=' . $this->config['dbname'] . ')))';
+ $dsn = 'oci:dbname=' . $dsn . ';charset=UTF8';
+ break;
+
case 'sqlsrv':
// prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress
// works for example, further parameters can still be appended using ;x=y
@@ -202,10 +217,16 @@ public function recreate_db()
break;
case 'phpbb\db\driver\oracle':
+ global $table_prefix;
$this->connect();
// Drop all of the tables
foreach ($this->get_tables() as $table)
{
+ if (strpos(strtolower($table_prefix), strtolower($table)) !== 0)
+ {
+ continue;
+ }
+
$this->pdo->exec('DROP TABLE ' . $table . ' CASCADE CONSTRAINTS');
}
$this->purge_extras();