diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index a2a3a04471..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,144 +0,0 @@ -build: false -clone_folder: c:\projects\phpbb -version: '{build}' - -services: - - iis - -environment: - COMPOSER_AUTH: - secure: '{"github-oauth": {"github.com": "zvq38wk7sRe87Y9W2OCYXcK7WKQDsig7GRIUDHGmxm6ZQRK8JswPbi8JoJQbFhM+"}}' - matrix: - - db: mssql - db_version: sql2012sp1 - php: 7.1 - - db: mssql - db_version: sql2014 - php: 7.1 - - db: mssql - db_version: sql2016 - php: 7.2 -# - db: mssql -# db_version: sql2017 -# php: 7.1 -# - db: mariadb -# php: 7.1 -# - db: mysqli -# php: 7.1 -# - db: sqlite -# php: 7.1 -# - db: postgresql -# php: 7.1 - -hosts: - phpbb.test: 127.0.0.1 - -init: - - SET PATH=%systemroot%\system32\inetsrv\;C:\Program Files\OpenSSL;C:\tools\php;c:\php;%PATH% - - SET ANSICON=121x90 (121x90) - - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f - -before_test: - - ps: | - Set-Service wuauserv -StartupType Manual - choco install chocolatey -y --version 0.10.13 --allow-downgrade - choco install php -y --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') - Get-ChildItem -Path "c:\tools\php$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1$2')" -Recurse | - Move-Item -destination "c:\tools\php" - cd c:\tools\php - cat php.ini-development | %{$_ -replace "memory_limit = 128M","memory_limit = 1024M"} | Out-File -Encoding "Default" php.ini - Add-Content php.ini "`n date.timezone=UTC" - Add-Content php.ini "`n display_errors=On" - Add-Content php.ini "`n extension_dir=ext" - Add-Content php.ini "`n extension=php_openssl.dll" - Add-Content php.ini "`n extension=php_mbstring.dll" - Add-Content php.ini "`n extension=php_curl.dll" - Add-Content php.ini "`n extension=php_gd2.dll" - Add-Content php.ini "`n extension=php_tidy.dll" - Add-Content php.ini "`n extension=php_fileinfo.dll" - Add-Content php.ini "`n extension=php_pdo_sqlite.dll" - Add-Content php.ini "`n extension=php_sqlite3.dll" - Add-Content php.ini "`n extension=php_pdo_mysql.dll" - Add-Content php.ini "`n extension=php_mysqli.dll" - Add-Content php.ini "`n extension=php_pdo_pgsql.dll" - Add-Content php.ini "`n extension=php_pgsql.dll" - - # Get MSSQL driver - if ($env:db -eq "mssql") { - cd c:\tools\php\ext - $DLLVersion = "5.3.0" - $VCVersion = If ([System.Version]"$($env:php)" -ge [System.Version]"7.2") {"vc15"} Else {"vc14"} - curl -o php_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-vc14-x64.zip https://windows.php.net/downloads/pecl/releases/sqlsrv/$($:DLLVersion)/php_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-$($VCVersion)-x64.zip - 7z x -y php_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-vc14-x64.zip > $null - curl -o php_pdo_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-vc14-x64.zip https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/$($DLLVersion)/php_pdo_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-$($VCVersion)-x64.zip - 7z x -y php_pdo_sqlsrv-$($DLLVersion)-$($env:php -replace '([0-9])[.]([0-9])[.]?([0-9]+)?','$1.$2')-nts-vc14-x64.zip > $null - Remove-Item c:\tools\php\* -include .zip - cd c:\tools\php - Add-Content php.ini "`nextension=php_sqlsrv.dll" - Add-Content php.ini "`nextension=php_pdo_sqlsrv.dll" - Add-Content php.ini "`n" - - $instanceName = $env:db_version.ToUpper() - Start-Service "MSSQL`$$instanceName" - Set-Variable -Name "sqlServerPath" -Value "(local)\$($env:db_version.ToUpper())" - - # Create database write test config - sqlcmd -S $sqlServerPath -Q "Use [master]; CREATE DATABASE [phpbb_test] COLLATE Latin1_General_CI_AS" - $data = "", "`n`t`n`t`t`n`t") | Set-Content c:\projects\phpbb\phpBB\web.config - (Get-Content c:\projects\phpbb\phpBB\web.config).replace("`t", "`t`t`n`t") | Set-Content c:\projects\phpbb\phpBB\web.config - - cd c:\projects\phpbb\phpBB - - php ..\composer.phar install - - choco install urlrewrite -y - - ps: New-WebSite -Name 'phpBBTest' -PhysicalPath 'c:\projects\phpbb\phpBB' -Force - - ps: Import-Module WebAdministration; Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'} - - echo Change default anonymous user AUTH to ApplicationPool - - appcmd set config -section:anonymousAuthentication /username:"" --password - - echo Setup FAST-CGI configuration - - appcmd set config /section:system.webServer/fastCGI /+[fullPath='C:\tools\php\php-cgi.exe'] - - echo Setup FACT-CGI handler - - appcmd set config /section:system.webServer/handlers /+[name='PHP-FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='C:\tools\php\php-cgi.exe',resourceType='Either'] - - iisreset - - NET START W3SVC - - mkdir "C:\projects\phpbb\phpBB\cache\test" - - mkdir "C:\projects\phpbb\phpBB\cache\installer" - - icacls "C:\projects\phpbb\phpBB\cache" /grant Users:F /T - - icacls "C:\projects\phpbb\phpBB\files" /grant Users:F /T - - icacls "C:\projects\phpbb\phpBB\store" /grant Users:F /T - - icacls "C:\projects\phpbb\phpBB\images\avatars\upload" /grant Users:F /T - -test_script: - - cd c:\projects\phpbb - - php -e phpBB\vendor\phpunit\phpunit\phpunit --verbose - diff --git a/.github/check-doctum-parse-errors.sh b/.github/check-doctum-parse-errors.sh new file mode 100755 index 0000000000..86abe86b36 --- /dev/null +++ b/.github/check-doctum-parse-errors.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +if [ ! -f doctum.phar ]; then + # Download the latest (5.1.x) release if the file does not exist + # Remove it to update your phar + curl -O https://doctum.long-term.support/releases/5.1/doctum.phar + rm -f doctum.phar.sha256 + curl -O https://doctum.long-term.support/releases/5.1/doctum.phar.sha256 + sha256sum --strict --check doctum.phar.sha256 + rm -f doctum.phar.sha256 + # You can fetch the latest (5.1.x) version code here: + # https://doctum.long-term.support/releases/5.1/VERSION +fi +# Show the version to inform users of the script +php doctum.phar --version +php doctum.phar parse build/doctum-checkout.conf.php -v diff --git a/.github/check-executable-files.sh b/.github/check-executable-files.sh new file mode 100755 index 0000000000..d9d0800f00 --- /dev/null +++ b/.github/check-executable-files.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +root="$1" +path="${root}phpBB/" + +# Check the permissions of the files + +# The following variables MUST NOT contain any wildcard +# Directories to skip +directories_skipped="-path ${path}develop -o -path ${path}vendor" + +# Files to skip +files_skipped="-false" + +# Files which have to be executable +executable_files="-path ${path}bin/* -o -path ${path}install/phpbbcli.php" + +incorrect_files=$( \ + find ${path} \ + '(' \ + '(' \ + ${directories_skipped} \ + ')' \ + -a -type d -prune -a -type f \ + ')' -o \ + '(' \ + -type f -a \ + -not '(' \ + ${files_skipped} \ + ')' -a \ + '(' \ + '(' \ + '(' \ + ${executable_files} \ + ')' -a \ + -not -perm /100 \ + ')' -o \ + '(' \ + -not '(' \ + ${executable_files} \ + ')' -a \ + -perm /111 \ + ')' \ + ')' \ + ')' \ + ) + +if [ "${incorrect_files}" != '' ] +then + echo "The following files do not have proper permissions:"; + ls -la ${incorrect_files} + exit 1; +fi diff --git a/.github/check-image-icc-profiles.sh b/.github/check-image-icc-profiles.sh new file mode 100755 index 0000000000..d0444dc7f5 --- /dev/null +++ b/.github/check-image-icc-profiles.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +find . -type f -a -iregex '.*\.\(gif\|jpg\|jpeg\|png\)$' -a -not -wholename '*vendor/*' | \ + parallel --gnu --keep-order 'phpBB/develop/strip_icc_profiles.sh {}' diff --git a/.github/ext-check-executable-files.sh b/.github/ext-check-executable-files.sh new file mode 100755 index 0000000000..09db25d40b --- /dev/null +++ b/.github/ext-check-executable-files.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +root="$1" +extname="$2" +path="${root}phpBB/ext/${extname}/" + +# Check the permissions of the files + +# The following variables MUST NOT contain any wildcard +# Directories to skip +directories_skipped="-path ${path}develop -o -path ${path}vendor -o -path ${path}.git" + +# Files to skip +files_skipped="-false" + +# Files which have to be executable +executable_files="-path ${path}bin/* -o -path ${path}install/phpbbcli.php" + +incorrect_files=$( \ + find ${path} \ + '(' \ + '(' \ + ${directories_skipped} \ + ')' \ + -a -type d -prune -a -type f \ + ')' -o \ + '(' \ + -type f -a \ + -not '(' \ + ${files_skipped} \ + ')' -a \ + '(' \ + '(' \ + '(' \ + ${executable_files} \ + ')' -a \ + -not -perm /100 \ + ')' -o \ + '(' \ + -not '(' \ + ${executable_files} \ + ')' -a \ + -perm /111 \ + ')' \ + ')' \ + ')' \ + ) + +if [ "${incorrect_files}" != '' ] +then + echo "The following files do not have proper permissions:"; + ls -la ${incorrect_files} + exit 1; +fi diff --git a/.github/ext-sniff.sh b/.github/ext-sniff.sh new file mode 100755 index 0000000000..fc5bafc008 --- /dev/null +++ b/.github/ext-sniff.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +EXTNAME=$1 +NOTESTS=$2 + +if [ "$NOTESTS" == "1" ] +then + phpBB/vendor/bin/phpcs \ + -s \ + --extensions=php \ + --standard=build/code_sniffer/ruleset-php-extensions.xml \ + --ignore=*/"$EXTNAME"/tests/*,*/"$EXTNAME"/vendor/* \ + phpBB/ext/"$EXTNAME" +fi diff --git a/.github/ldap/base.ldif b/.github/ldap/base.ldif new file mode 100644 index 0000000000..09fe7cecc6 --- /dev/null +++ b/.github/ldap/base.ldif @@ -0,0 +1,41 @@ +dn: dc=example,dc=com +objectClass: top +objectClass: dcObject +objectClass: organization +o: example +dc: example + +dn: ou=foo,dc=example,dc=com +objectClass: organizationalUnit +ou: foo + +dn: cn=admin,dc=example,dc=com +objectClass: simpleSecurityObject +objectClass: organizationalRole +cn: admin +description: LDAP administrator +userPassword:: e1NTSEF9NytMR2gveUxTMzdsc3RRd1V1dENZSVA0TWdYdm9SdDY= + +dn: ou=group,dc=example,dc=com +objectClass: organizationalUnit +ou: group + +dn: cn=admin,ou=foo,dc=example,dc=com +objectClass: posixAccount +objectClass: inetOrgPerson +objectClass: organizationalPerson +objectClass: person +loginShell: /bin/bash +homeDirectory: /home/admin +uid: admin +cn: admin +uidNumber: 10000 +gidNumber: 10000 +sn: admin +mail: admin@example.com +userPassword:: e1NTSEF9WHpueGZURHZZc21JSkl6czdMVXBjdCtWYTA1dlMzVlQ= + +dn: cn=admin,ou=group,dc=example,dc=com +objectClass: posixGroup +gidNumber: 10000 +cn: admin diff --git a/.github/ldap/slapd.conf b/.github/ldap/slapd.conf new file mode 100644 index 0000000000..9f6aa980f7 --- /dev/null +++ b/.github/ldap/slapd.conf @@ -0,0 +1,17 @@ +# See slapd.conf(5) for details on configuration options. +include /etc/ldap/schema/core.schema +include /etc/ldap/schema/cosine.schema +include /etc/ldap/schema/inetorgperson.schema +include /etc/ldap/schema/nis.schema + +pidfile /var/tmp/slapd/slapd.pid +argsfile /var/tmp/slapd/slapd.args + +modulepath /usr/lib/openldap + +database ldif +directory /var/tmp/slapd + +suffix "dc=example,dc=com" +rootdn "cn=admin,dc=example,dc=com" +rootpw adminadmin diff --git a/.github/phing-sniff.sh b/.github/phing-sniff.sh new file mode 100755 index 0000000000..7e1595c385 --- /dev/null +++ b/.github/phing-sniff.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +cd build +../phpBB/vendor/bin/phing sniff +cd .. diff --git a/.github/phpunit-mariadb-github.xml b/.github/phpunit-mariadb-github.xml new file mode 100644 index 0000000000..74b3b85483 --- /dev/null +++ b/.github/phpunit-mariadb-github.xml @@ -0,0 +1,39 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + diff --git a/.github/phpunit-mssql-github.xml b/.github/phpunit-mssql-github.xml new file mode 100644 index 0000000000..37c1deae2d --- /dev/null +++ b/.github/phpunit-mssql-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-mysql-github.xml b/.github/phpunit-mysql-github.xml new file mode 100644 index 0000000000..d14359d618 --- /dev/null +++ b/.github/phpunit-mysql-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-postgres-github.xml b/.github/phpunit-postgres-github.xml new file mode 100644 index 0000000000..2648f27bef --- /dev/null +++ b/.github/phpunit-postgres-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-psql-windows-github.xml b/.github/phpunit-psql-windows-github.xml new file mode 100644 index 0000000000..5f131bae80 --- /dev/null +++ b/.github/phpunit-psql-windows-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-sqlite3-github.xml b/.github/phpunit-sqlite3-github.xml new file mode 100644 index 0000000000..b079a0bbbe --- /dev/null +++ b/.github/phpunit-sqlite3-github.xml @@ -0,0 +1,35 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + diff --git a/.github/prepare-extension.sh b/.github/prepare-extension.sh new file mode 100755 index 0000000000..d3adc95ec5 --- /dev/null +++ b/.github/prepare-extension.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +EXTNAME=$1 + +# Move the extension in place +mkdir --parents phpBB/ext/$EXTNAME +cp -R ../tmp/* phpBB/ext/$EXTNAME + +# Move the test files for extensions in place +cp -R .github/*.xml phpBB/ext/$EXTNAME/.github +cp -R .github/*.sh phpBB/ext/$EXTNAME/.github diff --git a/.github/setup-database.sh b/.github/setup-database.sh new file mode 100755 index 0000000000..d34c7898b7 --- /dev/null +++ b/.github/setup-database.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +DB=$1 +MYISAM=$2 + +if [ "$DB" == "postgres" ] +then + psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres + psql -c 'create database phpbb_tests;' -U postgres +fi + +if [ "$MYISAM" == '1' ] +then + mysql -h 127.0.0.1 -u root -e 'SET GLOBAL storage_engine=MyISAM;' +fi diff --git a/.github/setup-exiftool.sh b/.github/setup-exiftool.sh new file mode 100755 index 0000000000..04999b8600 --- /dev/null +++ b/.github/setup-exiftool.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +sudo apt-get update +sudo apt-get install -y parallel libimage-exiftool-perl diff --git a/.github/setup-ldap.sh b/.github/setup-ldap.sh new file mode 100755 index 0000000000..d554654e87 --- /dev/null +++ b/.github/setup-ldap.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +sudo apt-get -y install ldap-utils slapd +mkdir /var/tmp/slapd +cp .github/ldap/slapd.conf /var/tmp/slapd/slapd.conf +slapd -d 256 -d 128 -f /var/tmp/slapd/slapd.conf -h ldap://localhost:3389 & +sleep 3 +ldapadd -h localhost:3389 -D "cn=admin,dc=example,dc=com" -w adminadmin -f .github/ldap/base.ldif diff --git a/.github/setup-phpbb.sh b/.github/setup-phpbb.sh new file mode 100755 index 0000000000..c74f29d5cf --- /dev/null +++ b/.github/setup-phpbb.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +DB=$1 +PHP_VERSION=$2 +NOTESTS=$3 + +if [ "$NOTESTS" == '1' ] +then + .github/setup-exiftool.sh + .github/setup-unbuffer.sh +fi + +if [ "$NOTESTS" != '1' ] +then + .github/setup-webserver.sh +fi + +cd phpBB +php ../composer.phar install --dev --no-interaction +if [[ "$PHP_VERSION" =~ ^nightly$ || "$PHP_VERSION" =~ ^8 ]] +then + 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 +fi +cd .. diff --git a/.github/setup-unbuffer.sh b/.github/setup-unbuffer.sh new file mode 100755 index 0000000000..4423d1b8b6 --- /dev/null +++ b/.github/setup-unbuffer.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +sudo apt-get update +sudo apt-get install -y expect-dev diff --git a/.github/setup-webserver.sh b/.github/setup-webserver.sh new file mode 100755 index 0000000000..0ee15ce061 --- /dev/null +++ b/.github/setup-webserver.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +sudo apt-get update +sudo apt-get install -y nginx coreutils + +sudo service nginx stop + +DIR=$(dirname "$0") +USER=$(whoami) +PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB") +NGINX_SITE_CONF="/etc/nginx/sites-enabled/default" +NGINX_CONF="/etc/nginx/nginx.conf" +APP_SOCK=$(realpath "$DIR")/php-app.sock +NGINX_PHP_CONF="$DIR/nginx-php.conf" + +# php-fpm +PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" +PHP_FPM_CONF="$DIR/php-fpm.conf" + +if [ ! -f $PHP_FPM_BIN ] && [ "$PHP_VERSION" == '8.1' ] && [ -f "/usr/bin/php-fpm" ] +then + PHP_FPM_BIN="/usr/bin/php-fpm" +fi + +if [ ! -f $PHP_FPM_BIN ] && [ "$PHP_VERSION" != '8.1' ] +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 \ + php$PHP_VERSION-zip php$PHP_VERSION-mysql php$PHP_VERSION-sqlite3 \ + php$PHP_VERSION-intl php$PHP_VERSION-gd php$PHP_VERSION-pgsql + sudo service php$PHP_VERSION-fpm start + sudo service php$PHP_VERSION-fpm status +fi + +echo " + [global] + + [ci] + user = $USER + group = $USER + listen = $APP_SOCK + listen.mode = 0666 + pm = static + pm.max_children = 2 + + php_admin_value[memory_limit] = 128M +" > $PHP_FPM_CONF + +sudo $PHP_FPM_BIN \ + --fpm-config "$DIR/php-fpm.conf" + +# nginx +sudo sed -i "s/user www-data;/user $USER;/g" $NGINX_CONF +sudo cp "$DIR/../phpBB/docs/nginx.sample.conf" "$NGINX_SITE_CONF" +sudo sed -i \ + -e "s/example\.com/localhost/g" \ + -e "s|root /path/to/phpbb;|root $PHPBB_ROOT_PATH;|g" \ + $NGINX_SITE_CONF + +# Generate FastCGI configuration for Nginx +echo " +upstream php { + server unix:$APP_SOCK; +} +" > $NGINX_PHP_CONF + +sudo mv "$NGINX_PHP_CONF" /etc/nginx/conf.d/php.conf + +sudo nginx -T +sudo service nginx start diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..9d45991111 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,448 @@ +name: Tests + +on: + push: + branches: + - 3.3.x + - master + pull_request: + branches: + - 3.3.x + - master + +jobs: + # Basic checks, e.g. parse errors, commit messages, etc. + basic-checks: + runs-on: ubuntu-18.04 + strategy: + matrix: + include: + - db: 'none' + php: '7.1' + NOTESTS: 1 + + name: PHP ${{ matrix.php }} - ${{ matrix.db }} + + steps: + - 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, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + coverage: none + + - 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 + env: + BRANCH: ${{ github.event.pull_request.base.ref }} + PR_SHA: ${{ github.event.pull_request.head.sha }} + if: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.base.ref != '' }} + run: | + git remote set-branches --add origin $BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$BRANCH..$PR_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: 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" + + 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: 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: + 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: 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 + + # Test with IIS & PostgreSQL on Windows + windows-tests: + runs-on: windows-2016 + strategy: + matrix: + include: + - php: '7.4' + 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: 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 + 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 + - name: Run unit tests + run: | + phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fd70ac1072..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -language: php -dist: xenial - -matrix: - include: - - php: 7.1 - env: DB=none;NOTESTS=1 - - php: 7.1 - env: DB=mariadb - - php: 7.1 - env: DB=postgres - - php: 7.1 - env: DB=sqlite3 - - php: 7.1 - env: DB=mysqli;SLOWTESTS=1 - - php: 7.1 - env: DB=mysqli # MyISAM - - php: 7.2 - env: DB=mysqli - - php: 7.3 - env: DB=mysqli - - php: 7.4 - env: DB=mysqli - - php: 7.4 - env: DB=mysqli;MYSQL8=1 - - php: 8.0snapshot - env: DB=mysqli - - php: nightly - env: DB=mysqli - allow_failures: - - php: nightly - fast_finish: true - -services: - - redis-server - - postgresql - - mysql - - memcached - -install: - - travis/setup-phpbb.sh $DB $TRAVIS_PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} - -before_script: - - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - - travis/setup-ldap.sh $SLOWTESTS - -script: - - travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - - travis/check-doctum-parse-errors.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - - travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION $NOTESTS ./ - - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi" - - sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error; fi" - - sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi" - - sh -c "set -x;if [ '$NOTESTS' = '1' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git remote set-branches --add origin $TRAVIS_BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..$TRAVIS_PULL_REQUEST_SHA; fi" diff --git a/README.md b/README.md index 1cb10c664b..277763c582 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,10 @@ phpBB's [Development Documentation](https://area51.phpbb.com/docs/dev/index.html We have unit and functional tests in order to prevent regressions. You can view the bamboo continuous integration [here](https://bamboo.phpbb.com) or check our travis builds below: -Branch | Description | Travis CI | AppVeyor -------- | ----------- | ---------- | -------- -**master** | Latest development version | [![Build Status](https://travis-ci.org/phpbb/phpbb.svg?branch=master)](http://travis-ci.org/phpbb/phpbb) | [![Build status](https://ci.appveyor.com/api/projects/status/8g98ybngd2f3axy1/branch/master?svg=true)](https://ci.appveyor.com/project/phpBB/phpbb/branch/master) -**3.3.x** | Development of version 3.3.x | [![Build Status](https://travis-ci.org/phpbb/phpbb.svg?branch=3.3.x)](http://travis-ci.org/phpbb/phpbb) | [![Build status](https://ci.appveyor.com/api/projects/status/8g98ybngd2f3axy1/branch/3.3.x?svg=true)](https://ci.appveyor.com/project/phpBB/phpbb/branch/3.3.x) -**3.2.x** | Development of version 3.2.x | [![Build Status](https://travis-ci.org/phpbb/phpbb.svg?branch=3.2.x)](http://travis-ci.org/phpbb/phpbb) | [![Build status](https://ci.appveyor.com/api/projects/status/8g98ybngd2f3axy1/branch/3.2.x?svg=true)](https://ci.appveyor.com/project/phpBB/phpbb/branch/3.2.x) +Branch | Description | Github Actions | +------- | ----------- | -------------- | +**master** | Latest development version | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=master) | +**3.3.x** | Development of version 3.3.x | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=3.3.x) | ## 📜 License diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 968c9762cc..e22d493a0f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -582,7 +582,37 @@ class acp_board continue; } - $config->set($config_name, $config_value); + // Array of emoji-enabled configurations + $config_name_ary = [ + 'sitename', + 'site_desc', + 'site_home_text', + 'board_index_text', + 'board_disable_msg', + ]; + + /** + * Event to manage the array of emoji-enabled configurations + * + * @event core.acp_board_config_emoji_enabled + * @var array config_name_ary Array of config names to process + * @since 3.3.3-RC1 + */ + $vars = ['config_name_ary']; + extract($phpbb_dispatcher->trigger_event('core.acp_board_config_emoji_enabled', compact($vars))); + + if (in_array($config_name, $config_name_ary)) + { + /** + * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR. + * Using their Numeric Character Reference's Hexadecimal notation. + */ + $config->set($config_name, utf8_encode_ucr($config_value)); + } + else + { + $config->set($config_name, $config_value); + } if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) { diff --git a/phpBB/mcp.php b/phpBB/mcp.php index a330bc65a5..582c8ed10b 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -333,12 +333,6 @@ $template->assign_block_vars('navlinks', array( 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}mcp.$phpEx"), )); -// Load and execute the relevant module -$module->load_active(); - -// Assign data to the template engine for the list of modules -$module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx")); - // Generate urls for letting the moderation control panel being accessed in different modes $template->assign_vars(array( 'U_MCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'), @@ -347,5 +341,11 @@ $template->assign_vars(array( 'U_MCP_POST' => ($forum_id && $topic_id && $post_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&t=$topic_id&p=$post_id") : '', )); +// Load and execute the relevant module +$module->load_active(); + +// Assign data to the template engine for the list of modules +$module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx")); + // Generate the page, do not display/query online list $module->display($module->get_page_title()); diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index a9137e8463..3f6bc49b35 100644 --- a/phpBB/phpbb/db/driver/oracle.php +++ b/phpBB/phpbb/db/driver/oracle.php @@ -45,30 +45,30 @@ class oracle extends \phpbb\db\driver\driver if ($new_link) { - if (!function_exists('ocinlogon')) + if (!function_exists('oci_new_connect')) { - $this->connect_error = 'ocinlogon function does not exist, is oci extension installed?'; + $this->connect_error = 'oci_new_connect function does not exist, is oci extension installed?'; return $this->sql_error(''); } - $this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8'); + $this->db_connect_id = @oci_new_connect($this->user, $sqlpassword, $connect, 'UTF8'); } else if ($this->persistency) { - if (!function_exists('ociplogon')) + if (!function_exists('oci_pconnect')) { - $this->connect_error = 'ociplogon function does not exist, is oci extension installed?'; + $this->connect_error = 'oci_pconnect function does not exist, is oci extension installed?'; return $this->sql_error(''); } - $this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8'); + $this->db_connect_id = @oci_pconnect($this->user, $sqlpassword, $connect, 'UTF8'); } else { - if (!function_exists('ocilogon')) + if (!function_exists('oci_connect')) { - $this->connect_error = 'ocilogon function does not exist, is oci extension installed?'; + $this->connect_error = 'oci_connect function does not exist, is oci extension installed?'; return $this->sql_error(''); } - $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'); + $this->db_connect_id = @oci_connect($this->user, $sqlpassword, $connect, 'UTF8'); } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); @@ -101,7 +101,7 @@ class oracle extends \phpbb\db\driver\driver $cache->put('oracle_version', $this->sql_server_version); } */ - $this->sql_server_version = @ociserverversion($this->db_connect_id); + $this->sql_server_version = @oci_server_version($this->db_connect_id); return $this->sql_server_version; } @@ -119,11 +119,11 @@ class oracle extends \phpbb\db\driver\driver break; case 'commit': - return @ocicommit($this->db_connect_id); + return @oci_commit($this->db_connect_id); break; case 'rollback': - return @ocirollback($this->db_connect_id); + return @oci_rollback($this->db_connect_id); break; } @@ -405,14 +405,14 @@ class oracle extends \phpbb\db\driver\driver break; } - $this->query_result = @ociparse($this->db_connect_id, $query); + $this->query_result = @oci_parse($this->db_connect_id, $query); foreach ($array as $key => $value) { - @ocibindbyname($this->query_result, $key, $array[$key], -1); + @oci_bind_by_name($this->query_result, $key, $array[$key], -1); } - $success = @ociexecute($this->query_result, OCI_DEFAULT); + $success = @oci_execute($this->query_result, OCI_DEFAULT); if (!$success) { @@ -481,7 +481,7 @@ class oracle extends \phpbb\db\driver\driver */ function sql_affectedrows() { - return ($this->query_result) ? @ocirowcount($this->query_result) : false; + return ($this->query_result) ? @oci_num_rows($this->query_result) : false; } /** @@ -503,10 +503,7 @@ class oracle extends \phpbb\db\driver\driver if ($query_id) { - $row = array(); - $result = ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); - - if (!$result || !$row) + if (!$row = oci_fetch_array($query_id, OCI_ASSOC + OCI_RETURN_NULLS)) { return false; } @@ -558,7 +555,7 @@ class oracle extends \phpbb\db\driver\driver } // Reset internal pointer - @ociexecute($query_id, OCI_DEFAULT); + @oci_execute($query_id, OCI_DEFAULT); // We do not fetch the row for rownum == 0 because then the next resultset would be the second row for ($i = 0; $i < $rownum; $i++) @@ -584,17 +581,17 @@ class oracle extends \phpbb\db\driver\driver if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) { $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL'; - $stmt = @ociparse($this->db_connect_id, $query); + $stmt = @oci_parse($this->db_connect_id, $query); if ($stmt) { - $success = @ociexecute($stmt, OCI_DEFAULT); + $success = @oci_execute($stmt, OCI_DEFAULT); if ($success) { - $temp_result = ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS); - ocifreestatement($stmt); + $temp_array = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS); + oci_free_statement($stmt); - if ($temp_result) + if (!empty($temp_array)) { return $temp_array['CURRVAL']; } @@ -630,7 +627,7 @@ class oracle extends \phpbb\db\driver\driver if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); - return ocifreestatement($query_id); + return oci_free_statement($query_id); } return false; @@ -683,11 +680,11 @@ class oracle extends \phpbb\db\driver\driver */ function _sql_error() { - if (function_exists('ocierror')) + if (function_exists('oci_error')) { - $error = @ocierror(); - $error = (!$error) ? @ocierror($this->query_result) : $error; - $error = (!$error) ? @ocierror($this->db_connect_id) : $error; + $error = @oci_error(); + $error = (!$error) ? @oci_error($this->query_result) : $error; + $error = (!$error) ? @oci_error($this->db_connect_id) : $error; if ($error) { @@ -715,7 +712,7 @@ class oracle extends \phpbb\db\driver\driver */ function _sql_close() { - return @ocilogoff($this->db_connect_id); + return @oci_close($this->db_connect_id); } /** @@ -734,11 +731,10 @@ class oracle extends \phpbb\db\driver\driver $sql = "SELECT table_name FROM USER_TABLES WHERE table_name LIKE '%PLAN_TABLE%'"; - $stmt = ociparse($this->db_connect_id, $sql); - ociexecute($stmt); - $result = array(); + $stmt = oci_parse($this->db_connect_id, $sql); + oci_execute($stmt); - if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS)) + if ($result = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS)) { $table = $result['TABLE_NAME']; @@ -746,17 +742,17 @@ class oracle extends \phpbb\db\driver\driver $statement_id = substr(md5($query), 0, 30); // Remove any stale plans - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); + $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); + oci_execute($stmt2); + oci_free_statement($stmt2); // Explain the plan $sql = "EXPLAIN PLAN SET STATEMENT_ID = '$statement_id' FOR $query"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); - ocifreestatement($stmt2); + $stmt2 = oci_parse($this->db_connect_id, $sql); + oci_execute($stmt2); + oci_free_statement($stmt2); // Get the data from the plan $sql = "SELECT operation, options, object_name, object_type, cardinality, cost @@ -764,24 +760,23 @@ class oracle extends \phpbb\db\driver\driver START WITH id = 0 AND statement_id = '$statement_id' CONNECT BY PRIOR id = parent_id AND statement_id = '$statement_id'"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); + $stmt2 = oci_parse($this->db_connect_id, $sql); + oci_execute($stmt2); - $row = array(); - while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS)) + while ($row = oci_fetch_array($stmt2, OCI_ASSOC + OCI_RETURN_NULLS)) { $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); } - ocifreestatement($stmt2); + oci_free_statement($stmt2); // Remove the plan we just made, we delete them on request anyway - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); + $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); + oci_execute($stmt2); + oci_free_statement($stmt2); } - ocifreestatement($stmt); + oci_free_statement($stmt); if ($html_table) { @@ -794,19 +789,19 @@ class oracle extends \phpbb\db\driver\driver $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1]; - $result = @ociparse($this->db_connect_id, $query); + $result = @oci_parse($this->db_connect_id, $query); if ($result) { - $success = @ociexecute($result, OCI_DEFAULT); + $success = @oci_execute($result, OCI_DEFAULT); if ($success) { - $row = array(); + array(); - while (ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) + while ($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS)) { // Take the time spent on parsing rows into account } - @ocifreestatement($result); + @oci_free_statement($result); } } diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php deleted file mode 100644 index 983bb42122..0000000000 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -use phpbb\install\exception\resource_limit_reached_exception; - -/** - * Create database schema - */ -class create_schema extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $config; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\db\tools\tools_interface - */ - protected $db_tools; - - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \phpbb\install\helper\config $config Installer's config provider - * @param \phpbb\install\helper\database $db_helper Installer's database helper - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param string $phpbb_root_path Path phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct(\phpbb\install\helper\config $config, - \phpbb\install\helper\database $db_helper, - \phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path, - $php_ext) - { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - $factory = new \phpbb\db\tools\factory(); - - $this->db = new $dbms(); - $this->db->sql_connect( - $config->get('dbhost'), - $config->get('dbuser'), - $config->get('dbpasswd'), - $config->get('dbname'), - $config->get('dbport'), - false, - false - ); - - $this->config = $config; - $this->db_tools = $factory->get($this->db); - $this->database_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - // As this task may take a large amount of time to complete refreshing the page might be necessary for some - // server configurations with limited resources - if (!$this->config->get('pre_schema_forced_refresh')) - { - if ($this->config->get_time_remaining() < 5) - { - $this->config->set('pre_schema_forced_refresh', true); - throw new resource_limit_reached_exception(); - } - } - - $this->db->sql_return_on_error(true); - - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $schema_name = $dbms_info[$dbms]['SCHEMA']; - $delimiter = $dbms_info[$dbms]['DELIM']; - $table_prefix = $this->config->get('table_prefix'); - - if ($dbms === 'mysql') - { - $schema_name .= '_41'; - } - - $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; - - // Load database vendor specific code if there is any - if ($this->filesystem->exists($db_schema_path)) - { - $sql_query = @file_get_contents($db_schema_path); - $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $sql_query = $this->database_helper->remove_comments($sql_query); - $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); - - foreach ($sql_query as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } - - unset($sql_query); - } - - $change_prefix = false; - - // Generate database schema - if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) - { - $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); - $db_table_schema = json_decode($db_table_schema, true); - $change_prefix = true; - } - else - { - global $table_prefix; - - $table_prefix = $this->config->get('table_prefix'); - - if (!defined('CONFIG_TABLE')) - { - // We need to include the constants file for the table constants - // when we generate the schema from the migration files. - include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); - } - - $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); - $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); - $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($this->db, true); - $schema_generator = new \phpbb\db\migration\schema_generator( - $migrator_classes, - new \phpbb\config\config(array()), - $this->db, - $db_tools, - $this->phpbb_root_path, - $this->php_ext, - $table_prefix - ); - $db_table_schema = $schema_generator->get_schema(); - } - - if (!defined('CONFIG_TABLE')) - { - // CONFIG_TABLE is required by sql_create_index() to check the - // length of index names. However table_prefix is not defined - // here yet, so we need to create the constant ourselves. - define('CONFIG_TABLE', $table_prefix . 'config'); - } - - foreach ($db_table_schema as $table_name => $table_data) - { - $this->db_tools->sql_create_table( - ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ), - $table_data - ); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_CREATE_DATABASE_SCHEMA'; - } -} diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 8af2fe12ad..bf7096ca42 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -259,7 +259,10 @@ class manager * Replace Emoji and other 4bit UTF-8 chars not allowed by MySQL * with their Numeric Character Reference's Hexadecimal notation. */ - $cp_data['pf_' . $row['field_ident']] = utf8_encode_ucr($cp_data['pf_' . $row['field_ident']]); + if (is_string($cp_data['pf_' . $row['field_ident']])) + { + $cp_data['pf_' . $row['field_ident']] = utf8_encode_ucr($cp_data['pf_' . $row['field_ident']]); + } $check_value = $cp_data['pf_' . $row['field_ident']]; diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php index 48982edc8c..9b77feaa86 100644 --- a/tests/functional/registration_test.php +++ b/tests/functional/registration_test.php @@ -118,4 +118,65 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case $form['config[coppa_enable]']->setValue('0'); $crawler = self::submit($form); } + + /** + * @depends test_disable_captcha_on_registration + */ + public function test_register_new_account_with_cpf_numbers() + { + $this->add_lang(['ucp', 'acp/profile']); + + // Create "Numbers" type CPF but don't set its default value + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_profile&mode=profile&sid={$this->sid}"); + $form = $crawler->selectButton('submit')->form([ // Create new field + 'field_type' => 'profilefields.type.int', + ]); + $crawler = self::submit($form); + + $this->assertContainsLang('STEP_1_TITLE_CREATE', $this->get_content()); + $this->assertStringContainsString('Numbers', $crawler->filter('dl > dd > strong')->text()); + + $form = $crawler->selectButton('next')->form([ // Go to Profile type specific options + 'field_ident' => 'Numbers', + 'lang_name' => 'Numbers CPF', + ]); + $form['field_show_on_reg']->tick(); + $crawler = self::submit($form); + + $this->assertContainsLang('STEP_2_TITLE_CREATE', $this->get_content()); + + $form = $crawler->selectButton('Save')->form(); // Save CPF + self::submit($form); + $this->assertContainsLang('ADDED_PROFILE_FIELD', $this->get_content()); + + $this->logout(); + + // Get into registration process + // Check that we can't skip + self::request('GET', 'ucp.php?mode=register&agreed=1'); + $this->assertContainsLang('AGREE', $this->get_content()); + + $crawler = self::request('GET', 'ucp.php?mode=register'); + $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); + + $form = $crawler->selectButton('I agree to these terms')->form(); + $crawler = self::submit($form); + + // Check if Numbers CPF displayed on registration + $this->assertStringContainsString('Numbers CPF', $crawler->filter('label[for="pf_numbers"]')->text()); + + $form = $crawler->selectButton('Submit')->form(array( + 'username' => 'user-reg-test1', + 'email' => 'user-reg-test1@phpbb.com', + 'new_password' => 'user-reg-testuser-reg-test1', + 'password_confirm' => 'user-reg-testuser-reg-test1', + )); + $form['tz']->select('Europe/Berlin'); + $crawler = self::submit($form); + + $this->assertContainsLang('ACCOUNT_ADDED', $crawler->filter('#message')->text()); + } } diff --git a/tests/functional/search/mysql_test.php b/tests/functional/search/mysql_test.php index a97b12e905..f7e6cbf5f1 100644 --- a/tests/functional/search/mysql_test.php +++ b/tests/functional/search/mysql_test.php @@ -20,4 +20,17 @@ class phpbb_functional_search_mysql_test extends phpbb_functional_search_base { protected $search_backend = '\phpbb\search\fulltext_mysql'; + protected function create_search_index($backend = null) + { + parent::create_search_index($backend); + + // Try optimizing posts table after creating search index. + // Some versions of MariaDB might not return any results in the search + // until the table has been optimized or the index deleted and re-created. + $db = $this->get_db(); + $db->sql_return_on_error(true); + $sql = 'OPTIMIZE TABLE ' . POSTS_TABLE; + $db->sql_query($sql); + $db->sql_return_on_error(false); + } }