From 46d0cf7bb404291498511010b25de8ff691574ef Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 29 Sep 2020 22:13:19 +0700 Subject: [PATCH 01/41] [ticket/16607] Update Oracle DBAL driver OCI8 aliases and functions PHPBB3-16607 --- phpBB/phpbb/db/driver/oracle.php | 107 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index f2a0bb557a..0da9966373 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); } } From ec3a2fa0630ec42c75a14392b2bf6f0e5398376b Mon Sep 17 00:00:00 2001 From: "Tseng, Oliver" Date: Mon, 23 Nov 2020 23:35:10 -0500 Subject: [PATCH 02/41] [ticket/16640] Show MCP link in menu PHPBB3-16640 --- phpBB/mcp.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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()); From 022b58f986c991d5dd0ba69fa5523026c2422331 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 28 Nov 2020 17:52:27 +0700 Subject: [PATCH 03/41] [ticket/16582] Fix SQL error on registration with Numbers CPF with no default PHPBB3-16582 --- phpBB/phpbb/profilefields/manager.php | 5 ++- tests/functional/registration_test.php | 61 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) 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()); + } } From cbf98a2d7d981c58a61448531c06ca12847e343f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 22 Nov 2020 17:13:30 +0100 Subject: [PATCH 04/41] [ticket/16659] Start setting up test workflow on github actions PHPBB3-16659 --- .github/workflows/tests.yml | 108 ++++++++++++++++++ ...li-travis.xml => phpunit-mysql-travis.xml} | 0 travis/phpunit-postgres-travis.xml | 2 +- 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml rename travis/{phpunit-mysqli-travis.xml => phpunit-mysql-travis.xml} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..4e88c6a958 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,108 @@ +name: Tests + +on: + push: + branches: + - 3.3.x + - master + - task/github-actions + pull_request: + branches: + - 3.3.x + - master + +jobs: + unit-tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php: [7.4, 7.3, 7.2] + db: + - mysql:5.6 + - mysql:5.7 + - mysql:8.0 + - postgres:9.5 + - postgres:9.6 + - postgres:10 + - postgres:11 + - postgres:12 + - postgres:13 + - sqlite3 + + name: PHP${{ matrix.php }} - ${{ matrix.db }} + + services: + mysql: + if: startsWith(${{ matrix.db }}, 'mysql') + image: ${{ matrix.db }} + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + postgres: + if: startsWith(${{ matrix.db }}, 'postgres') + image: ${{ matrix.db }} + env: + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + options: >- + --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 + + + 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 environment for phpBB + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: 0 + MYSQL8: ${{ matrix.db }} == 'mysql:8.0' + run: | + travis/setup-phpbb.sh $DB PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} + + - name: Setup database + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: 0 + run: | + travis/setup-database.sh $DB $PHP_VERSION $NOTESTS + + - name: Run unit tests + env: + DB: ${{steps.database-type.outputs.db}} + run: | + phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + # - name: Run test suite + # run: composer run-script test diff --git a/travis/phpunit-mysqli-travis.xml b/travis/phpunit-mysql-travis.xml similarity index 100% rename from travis/phpunit-mysqli-travis.xml rename to travis/phpunit-mysql-travis.xml diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 3d8376bda1..2648f27bef 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -32,7 +32,7 @@ - + From ba75aa9d0ced6aaab575c2bbff5e5537794326d1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 22 Nov 2020 17:21:08 +0100 Subject: [PATCH 05/41] [ticket/16659] Limit tests to mysql for now PHPBB3-16659 --- .github/workflows/tests.yml | 53 +++++++++++++++++++++---------------- travis/setup-database.sh | 4 +-- travis/setup-phpbb.sh | 5 ---- travis/setup-webserver.sh | 6 ++--- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e88c6a958..6e84061879 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,23 +21,23 @@ jobs: db: - mysql:5.6 - mysql:5.7 - - mysql:8.0 - - postgres:9.5 - - postgres:9.6 - - postgres:10 - - postgres:11 - - postgres:12 - - postgres:13 - - sqlite3 +# - mysql:8.0 +# - postgres:9.5 +# - postgres:9.6 +# - postgres:10 +# - postgres:11 +# - postgres:12 +# - postgres:13 +# - sqlite3 name: PHP${{ matrix.php }} - ${{ matrix.db }} services: mysql: - if: startsWith(${{ matrix.db }}, 'mysql') image: ${{ matrix.db }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: phpbb_tests ports: - 3306:3306 options: >- @@ -46,18 +46,18 @@ jobs: --health-timeout=5s --health-retries=3 - postgres: - if: startsWith(${{ matrix.db }}, 'postgres') - image: ${{ matrix.db }} - env: - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 +# postgres: +# if: startsWith(${{ matrix.db }}, 'postgres') +# image: ${{ matrix.db }} +# env: +# POSTGRES_PASSWORD: postgres +# ports: +# - 5432:5432 +# options: >- +# --health-cmd pg_isready +# --health-interval 10s +# --health-timeout 5s +# --health-retries 5 redis: image: redis options: >- @@ -78,14 +78,21 @@ jobs: db=$(echo "${MATRIX_DB%%:*}") echo "::set-output name=db::$db" + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extension: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, pdo_mysqli, intl, gd, exif, iconv + coverage: none + - name: Setup environment for phpBB env: DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} + CI_PHP_VERSION: ${{ matrix.php }} NOTESTS: 0 MYSQL8: ${{ matrix.db }} == 'mysql:8.0' run: | - travis/setup-phpbb.sh $DB PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} + travis/setup-phpbb.sh $DB CI_PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} - name: Setup database env: diff --git a/travis/setup-database.sh b/travis/setup-database.sh index b581ddfccb..602d55678e 100755 --- a/travis/setup-database.sh +++ b/travis/setup-database.sh @@ -26,12 +26,12 @@ then psql -c 'create database phpbb_tests;' -U postgres fi -if [ "$TRAVIS_PHP_VERSION" == "5.6" -a "$DB" == "mysqli" ] +if [ "$TRAVIS_PHP_VERSION" == "5.6" -a "$DB" == "mysql" ] then mysql -e 'SET GLOBAL storage_engine=MyISAM;' fi -if [ "$DB" == "mysqli" -o "$DB" == "mariadb" ] +if [ "$DB" == "mariadb" ] then mysql -e 'create database IF NOT EXISTS phpbb_tests;' fi diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index 208b715dfe..7c089d76db 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -32,11 +32,6 @@ then travis/setup-mysql8.sh fi -if [ "$NOTESTS" != '1' ] -then - travis/setup-php-extensions.sh -fi - if [ "$NOTESTS" != '1' ] then travis/setup-webserver.sh diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index 68bcd6ac00..35cdb0ebf4 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -12,7 +12,7 @@ set -e set -x sudo apt-get update -sudo apt-get install -y nginx realpath +sudo apt-get install -y nginx coreutils sudo service nginx stop @@ -25,13 +25,13 @@ APP_SOCK=$(realpath "$DIR")/php-app.sock NGINX_PHP_CONF="$DIR/nginx-php.conf" # php-fpm -PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm" +PHP_FPM_BIN="/usr/sbin/php-fpm$CI_PHP_VERSION" PHP_FPM_CONF="$DIR/php-fpm.conf" echo " [global] - [travis] + [ci] user = $USER group = $USER listen = $APP_SOCK From 1710a38ced5d58bea7f57a521ae42208744e46a6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 29 Nov 2020 21:37:25 +0100 Subject: [PATCH 06/41] [ticket/16659] Add postgres tests PHPBB3-16659 --- .github/workflows/tests.yml | 85 +++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e84061879..0abe850093 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,27 +14,52 @@ on: jobs: unit-tests: runs-on: ubuntu-latest - strategy: matrix: - php: [7.4, 7.3, 7.2] - db: - - mysql:5.6 - - mysql:5.7 -# - mysql:8.0 -# - postgres:9.5 -# - postgres:9.6 -# - postgres:10 -# - postgres:11 -# - postgres:12 -# - postgres:13 -# - sqlite3 + include: +# - php: 7.1 +# db: "none" +# NOTESTS: 1 +# - 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: "postgres:9.5" + - 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.1 +# db: "sqlite3" + - php: 7.1 + db: "mysql:5.6" + - php: 7.1 + db: "mysql:5.7" +# - php: 7.1 +# db: "mysql:8.0" +# - php: 7.2 +# db: "mysql:5.7" +# - php: 7.3 +# db: "mysql:5.7" +# - php: 7.4 +# db: "mysql:5.7" - name: PHP${{ matrix.php }} - ${{ matrix.db }} + name: PHP ${{ matrix.php }} - ${{ matrix.db }} services: mysql: - image: ${{ matrix.db }} + image: ${{ matrix.db != 'mysql:5.6' && matrix.db != 'mysql:5.7' && matrix.db != 'mysql:8.0' && 'mysql:5.7' || matrix.db }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: phpbb_tests @@ -46,18 +71,20 @@ jobs: --health-timeout=5s --health-retries=3 -# postgres: -# if: startsWith(${{ matrix.db }}, 'postgres') -# image: ${{ matrix.db }} -# env: -# POSTGRES_PASSWORD: postgres -# ports: -# - 5432:5432 -# options: >- -# --health-cmd pg_isready -# --health-interval 10s -# --health-timeout 5s -# --health-retries 5 + 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: >- @@ -65,6 +92,8 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + ports: + - 6379:6379 steps: @@ -82,7 +111,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extension: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, pdo_mysqli, intl, gd, exif, iconv + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, pdo_mysqli, intl, gd, exif, iconv coverage: none - name: Setup environment for phpBB From d76488839322f3f9eae58e35db2d1e212c24f6cb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 1 Dec 2020 20:52:23 +0100 Subject: [PATCH 07/41] [ticket/16659] Enable sqlite3 tests PHPBB3-16659 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0abe850093..8f255147c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,8 +40,8 @@ jobs: # db: "postgres:12" # - php: 7.1 # db: "postgres:13" -# - php: 7.1 -# db: "sqlite3" + - php: 7.1 + db: "sqlite3" - php: 7.1 db: "mysql:5.6" - php: 7.1 From 5cbe25d415224b414e5c9211707e823d569a8d96 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 1 Dec 2020 21:28:12 +0100 Subject: [PATCH 08/41] [ticket/16659] Enable mariadb tests PHPBB3-16659 --- .github/workflows/tests.yml | 6 +++--- travis/setup-phpbb.sh | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8f255147c5..39b04bb9fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,8 +24,8 @@ jobs: # db: "mariadb:10.1" # - php: 7.1 # db: "mariadb:10.2" -# - php: 7.1 -# db: "mariadb:10.3" + - php: 7.1 + db: "mariadb:10.3" # - php: 7.1 # db: "mariadb:10.4" # - php: 7.1 @@ -59,7 +59,7 @@ jobs: services: mysql: - image: ${{ matrix.db != 'mysql:5.6' && matrix.db != 'mysql:5.7' && matrix.db != 'mysql:8.0' && 'mysql:5.7' || matrix.db }} + image: ${{ matrix.db != 'mysql:5.6' && matrix.db != 'mysql:5.7' && matrix.db != 'mysql:8.0' && matrix.db != 'mariadb:10.1' && matrix.db != 'mariadb:10.2' && matrix.db != 'mariadb:10.3' && matrix.db != 'mariadb:10.4' && matrix.db != 'mariadb:10.5' && 'mysql:5.7' || matrix.db }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: phpbb_tests diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index 7c089d76db..a6e51b5ed9 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -22,11 +22,6 @@ then travis/setup-unbuffer.sh fi -if [ "$DB" == "mariadb" ] -then - travis/setup-mariadb.sh -fi - if [ "$MYSQL8" == '1' ] then travis/setup-mysql8.sh From 2cdebe57afa2fed5153a3f782a5cfd6053a83f49 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Dec 2020 16:25:42 +0100 Subject: [PATCH 09/41] [ticket/16659] Use volume for /var/run/mysqld PHPBB3-16659 --- .github/workflows/tests.yml | 1 + travis/setup-phpbb.sh | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 39b04bb9fd..46cd9cb718 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -66,6 +66,7 @@ jobs: ports: - 3306:3306 options: >- + -v /srv/docker/sockets/mariadb:/var/run/mysqld --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index a6e51b5ed9..9bf19242ca 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -22,6 +22,15 @@ then travis/setup-unbuffer.sh fi +if [ "$DB" == "mariadb" ] +then + ls -l /var/run | grep -i mysqld + + if [ ! -f "/var/run/mysqld/mysqld.sock" ]; then + ln -s /srv/docker/sockets/mariadb/mysqld.sock /var/run/mysqld/mysqld.sock + fi +fi + if [ "$MYSQL8" == '1' ] then travis/setup-mysql8.sh From 5b82ca23d3c15a534d3a48d4e4fbbc036416b865 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2020 17:21:53 +0100 Subject: [PATCH 10/41] [ticket/16659] Remove special definitions for mariadb setup PHPBB3-16659 --- .github/workflows/tests.yml | 1 - travis/setup-database.sh | 5 ----- travis/setup-phpbb.sh | 9 --------- 3 files changed, 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 46cd9cb718..39b04bb9fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -66,7 +66,6 @@ jobs: ports: - 3306:3306 options: >- - -v /srv/docker/sockets/mariadb:/var/run/mysqld --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s diff --git a/travis/setup-database.sh b/travis/setup-database.sh index 602d55678e..0a4085158d 100755 --- a/travis/setup-database.sh +++ b/travis/setup-database.sh @@ -30,8 +30,3 @@ if [ "$TRAVIS_PHP_VERSION" == "5.6" -a "$DB" == "mysql" ] then mysql -e 'SET GLOBAL storage_engine=MyISAM;' fi - -if [ "$DB" == "mariadb" ] -then - mysql -e 'create database IF NOT EXISTS phpbb_tests;' -fi diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index 9bf19242ca..a6e51b5ed9 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -22,15 +22,6 @@ then travis/setup-unbuffer.sh fi -if [ "$DB" == "mariadb" ] -then - ls -l /var/run | grep -i mysqld - - if [ ! -f "/var/run/mysqld/mysqld.sock" ]; then - ln -s /srv/docker/sockets/mariadb/mysqld.sock /var/run/mysqld/mysqld.sock - fi -fi - if [ "$MYSQL8" == '1' ] then travis/setup-mysql8.sh From 1e985dc4f014802157e3ba1da2c6313cf51d975d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2020 17:49:06 +0100 Subject: [PATCH 11/41] [ticket/16659] Add PHP 8.0 and notests run PHPBB3-16659 --- .github/workflows/tests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 39b04bb9fd..6747e9f5db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,9 +17,9 @@ jobs: strategy: matrix: include: -# - php: 7.1 -# db: "none" -# NOTESTS: 1 + - php: 7.1 + db: "none" + NOTESTS: 1 # - php: 7.1 # db: "mariadb:10.1" # - php: 7.1 @@ -46,14 +46,16 @@ jobs: db: "mysql:5.6" - php: 7.1 db: "mysql:5.7" -# - php: 7.1 -# db: "mysql:8.0" + - php: 7.1 + db: "mysql:8.0" # - php: 7.2 # db: "mysql:5.7" # - php: 7.3 # db: "mysql:5.7" # - php: 7.4 # db: "mysql:5.7" + - php: 8.0 + db: "mysql:5.7" name: PHP ${{ matrix.php }} - ${{ matrix.db }} From 0907087ee310db720e7e3595a518b584e5b2d584 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2020 21:05:09 +0100 Subject: [PATCH 12/41] [ticket/16659] Add steps for notests run PHPBB3-16659 --- .github/workflows/tests.yml | 82 +++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6747e9f5db..26c4cd1f44 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,38 +24,38 @@ jobs: # db: "mariadb:10.1" # - php: 7.1 # db: "mariadb:10.2" - - php: 7.1 - db: "mariadb:10.3" +# - 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: "postgres:9.5" - - php: 7.1 - db: "postgres:10" +# - 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.1 - db: "sqlite3" - - php: 7.1 - db: "mysql:5.6" - - php: 7.1 - db: "mysql:5.7" - - php: 7.1 - db: "mysql:8.0" +# - php: 7.1 +# db: "sqlite3" +# - php: 7.1 +# db: "mysql:5.6" +# - php: 7.1 +# db: "mysql:5.7" +# - php: 7.1 +# db: "mysql:8.0" # - php: 7.2 # db: "mysql:5.7" # - php: 7.3 # db: "mysql:5.7" # - php: 7.4 # db: "mysql:5.7" - - php: 8.0 - db: "mysql:5.7" +# - php: 8.0 +# db: "mysql:5.7" name: PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -120,7 +120,7 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} CI_PHP_VERSION: ${{ matrix.php }} - NOTESTS: 0 + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} MYSQL8: ${{ matrix.db }} == 'mysql:8.0' run: | travis/setup-phpbb.sh $DB CI_PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} @@ -129,16 +129,66 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: 0 + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} run: | travis/setup-database.sh $DB $PHP_VERSION $NOTESTS + - name: Phing sniff + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + if: ${{ matrix.NOTESTS == 1 }} + run: | + travis/phing-sniff.sh $DB $PHP_VERSION $NOTESTS + + - name: Check doctum parse errors + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + if: ${{ matrix.NOTESTS == 1 }} + run: | + travis/check-doctum-parse-errors.sh $DB $PHP_VERSION $NOTESTS + + - name: Check image ICC profiles + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + if: ${{ matrix.NOTESTS == 1 }} + run: | + travis/check-image-icc-profiles.sh $DB $PHP_VERSION $NOTESTS + + - name: Check image ICC profiles + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + if: ${{ matrix.NOTESTS == 1 }} + run: | + travis/check-executable-files.sh $DB $PHP_VERSION $NOTESTS ./ + + - 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 travis/phpunit-$DB-travis.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 travis/phpunit-$DB-travis.xml --group slow + + # @todo: Add commit message check + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" # Docs: https://getcomposer.org/doc/articles/scripts.md From c22cacf9bd8749320c0f82e8b80dbcd98bd2d8f9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2020 21:09:27 +0100 Subject: [PATCH 13/41] [ticket/16659] Test with PHP 8 PHPBB3-16659 --- .github/workflows/tests.yml | 26 +++++++++++++------------- travis/setup-webserver.sh | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 26c4cd1f44..5948236511 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,8 @@ jobs: - php: 7.1 db: "none" NOTESTS: 1 -# - php: 7.1 -# db: "mariadb:10.1" + - php: 7.1 + db: "mariadb:10.1" # - php: 7.1 # db: "mariadb:10.2" # - php: 7.1 @@ -54,8 +54,8 @@ jobs: # db: "mysql:5.7" # - php: 7.4 # db: "mysql:5.7" -# - php: 8.0 -# db: "mysql:5.7" + - php: '8.0' + db: "mysql:5.7" name: PHP ${{ matrix.php }} - ${{ matrix.db }} @@ -119,17 +119,17 @@ jobs: - name: Setup environment for phpBB env: DB: ${{steps.database-type.outputs.db}} - CI_PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} MYSQL8: ${{ matrix.db }} == 'mysql:8.0' run: | - travis/setup-phpbb.sh $DB CI_PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} + travis/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} - name: Setup database env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} run: | travis/setup-database.sh $DB $PHP_VERSION $NOTESTS @@ -137,7 +137,7 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} if: ${{ matrix.NOTESTS == 1 }} run: | travis/phing-sniff.sh $DB $PHP_VERSION $NOTESTS @@ -146,7 +146,7 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} if: ${{ matrix.NOTESTS == 1 }} run: | travis/check-doctum-parse-errors.sh $DB $PHP_VERSION $NOTESTS @@ -155,16 +155,16 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} if: ${{ matrix.NOTESTS == 1 }} run: | travis/check-image-icc-profiles.sh $DB $PHP_VERSION $NOTESTS - - name: Check image ICC profiles + - name: Check executable files env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && 0 || 1 }} + NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} if: ${{ matrix.NOTESTS == 1 }} run: | travis/check-executable-files.sh $DB $PHP_VERSION $NOTESTS ./ diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index 35cdb0ebf4..68053c1f7a 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -25,7 +25,7 @@ APP_SOCK=$(realpath "$DIR")/php-app.sock NGINX_PHP_CONF="$DIR/nginx-php.conf" # php-fpm -PHP_FPM_BIN="/usr/sbin/php-fpm$CI_PHP_VERSION" +PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" PHP_FPM_CONF="$DIR/php-fpm.conf" echo " From bb020c3e6be7fa6910ed33045b5983c7e9f91187 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Dec 2020 11:24:10 +0100 Subject: [PATCH 14/41] [ticket/16659] Make sure php-fpm is installed PHPBB3-16659 --- .github/workflows/tests.yml | 2 +- travis/setup-webserver.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5948236511..0c223d0fb3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -113,7 +113,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, pdo_mysqli, intl, gd, exif, iconv + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv coverage: none - name: Setup environment for phpBB diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index 68053c1f7a..ea903ae1fe 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -28,6 +28,16 @@ NGINX_PHP_CONF="$DIR/nginx-php.conf" PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" PHP_FPM_CONF="$DIR/php-fpm.conf" +if [ ! -f $PHP_FPM_BIN ] +then + sudo apt-get install php$PHP_VERSION-fpm php$PHP_VERSION-cli php$PHP_VERSION-dom \ + 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] From 4729be9e96755b11ec6ed36ad30b257d7e597378 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Dec 2020 13:46:22 +0100 Subject: [PATCH 15/41] [ticket/16659] Add builds for MySQL 8 and PHP 8.1 PHPBB3-16659 --- .github/workflows/tests.yml | 6 ++++-- travis/setup-webserver.sh | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c223d0fb3..93d5fd4026 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,16 +46,18 @@ jobs: # db: "mysql:5.6" # - php: 7.1 # db: "mysql:5.7" -# - php: 7.1 -# db: "mysql:8.0" # - 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 }} diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index ea903ae1fe..af6fccfe53 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -28,7 +28,12 @@ NGINX_PHP_CONF="$DIR/nginx-php.conf" PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" PHP_FPM_CONF="$DIR/php-fpm.conf" -if [ ! -f $PHP_FPM_BIN ] +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-dom \ php$PHP_VERSION-curl php$PHP_VERSION-xml php$PHP_VERSION-mbstring \ From d6e1989e1f7dba95b36244099cf07ca2767f9e4a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Dec 2020 14:50:46 +0100 Subject: [PATCH 16/41] [ticket/16659] First test run with all current tests PHPBB3-16659 --- .github/workflows/tests.yml | 70 +++++++++++++++++++------------------ travis/setup-database.sh | 5 +-- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93d5fd4026..2c50ded105 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,42 +17,43 @@ jobs: strategy: matrix: include: - - php: 7.1 + - php: '7.1' db: "none" NOTESTS: 1 - - php: 7.1 + - 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: "postgres:9.5" -# - 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.1 -# db: "sqlite3" -# - 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 + - 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: "postgres:9.5" + - 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.1' + db: "sqlite3" + - php: '7.1' + db: "mysql:5.6" + MYISAM: 1 + - 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" @@ -132,8 +133,9 @@ jobs: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} + MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} run: | - travis/setup-database.sh $DB $PHP_VERSION $NOTESTS + travis/setup-database.sh $DB $PHP_VERSION $NOTESTS $MYISAM - name: Phing sniff env: diff --git a/travis/setup-database.sh b/travis/setup-database.sh index 0a4085158d..479e17f592 100755 --- a/travis/setup-database.sh +++ b/travis/setup-database.sh @@ -14,6 +14,7 @@ set -x DB=$1 TRAVIS_PHP_VERSION=$2 NOTESTS=$3 +MYISAM=$4 if [ "$NOTESTS" == '1' ] then @@ -26,7 +27,7 @@ then psql -c 'create database phpbb_tests;' -U postgres fi -if [ "$TRAVIS_PHP_VERSION" == "5.6" -a "$DB" == "mysql" ] +if [ "$MYISAM" == '1' ] then - mysql -e 'SET GLOBAL storage_engine=MyISAM;' + mysql -h 127.0.0.1 -u root -e 'SET GLOBAL storage_engine=MyISAM;' fi From 4f282db6e20e1f9d773bdb53ff9794a271584086 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Dec 2020 14:23:18 +0100 Subject: [PATCH 17/41] [ticket/16659] Resolve issues with fulltext search in mariadb PHPBB3-16659 --- tests/functional/search/mysql_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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); + } } From 6c9ecf1cc88b08d969d4b42bc9acc124e9344691 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Dec 2020 17:30:36 +0100 Subject: [PATCH 18/41] [ticket/16659] Add tests for MSSQL PHPBB3-16659 --- .github/workflows/tests.yml | 110 +++++++++++++++++++------------- travis/phpunit-mssql-travis.xml | 41 ++++++++++++ 2 files changed, 107 insertions(+), 44 deletions(-) create mode 100644 travis/phpunit-mssql-travis.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c50ded105..fe2dc6cea2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,52 +13,54 @@ on: jobs: unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 strategy: matrix: include: - - php: '7.1' - db: "none" - NOTESTS: 1 - - 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: "postgres:9.5" - - 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.1' - db: "sqlite3" - - php: '7.1' - db: "mysql:5.6" - MYISAM: 1 - - php: '7.1' - db: "mysql:5.7" +# - php: '7.1' +# db: "none" +# NOTESTS: 1 +# - 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: "postgres:9.5" +# - 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.1' +# db: "sqlite3" +# - php: '7.1' +# db: "mysql:5.6" +# MYISAM: 1 +# - 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" + db: "mcr.microsoft.com/mssql/server:2017-latest" +# - 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 }} @@ -90,6 +92,21 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + + 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: >- @@ -109,14 +126,19 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - db=$(echo "${MATRIX_DB%%:*}") + 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 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv coverage: none - name: Setup environment for phpBB diff --git a/travis/phpunit-mssql-travis.xml b/travis/phpunit-mssql-travis.xml new file mode 100644 index 0000000000..37c1deae2d --- /dev/null +++ b/travis/phpunit-mssql-travis.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + From e2f21b3dd3246ce9d85f185ca235952a46eb69a1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 15 Dec 2020 22:10:08 +0100 Subject: [PATCH 19/41] [ticket/16659] Use matrix db alias for MSSQL builds PHPBB3-16659 --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe2dc6cea2..54b5952a3d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,6 +49,7 @@ jobs: # db: "mysql:5.7" - php: '7.2' db: "mcr.microsoft.com/mssql/server:2017-latest" + db_alias: 'MSSQL 2017' # - php: '7.2' # db: "mysql:5.7" # - php: '7.3' @@ -62,7 +63,7 @@ jobs: # - php: '8.1' # db: "mysql:5.7" - name: PHP ${{ matrix.php }} - ${{ matrix.db }} + name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} services: mysql: From bff3c7c7affa4b98e229711b65573e25521c31cd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 15 Dec 2020 22:18:21 +0100 Subject: [PATCH 20/41] [ticket/16659] Add slow tests PHPBB3-16659 --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54b5952a3d..6a7a470f65 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,6 +42,9 @@ jobs: # db: "postgres:13" # - php: '7.1' # db: "sqlite3" + - php: '7.1' + db: "mysql:5.6" + SLOWTESTS: 1 # - php: '7.1' # db: "mysql:5.6" # MYISAM: 1 From c2c2c3f62bad1aef406d037dbfe59f1cc90b225f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 15 Dec 2020 22:33:18 +0100 Subject: [PATCH 21/41] [ticket/16659] Add commit message check PHPBB3-16659 --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6a7a470f65..574724383d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -217,6 +217,13 @@ jobs: run: | phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow + - name: Check commit message + env: + BRANCH: ${{ github.event.pull_request.base.ref }} + PR_SHA: ${{ github.event.pull_request.head.sha }} + if: ${{ matrix.NOTESTS == 1 && 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 # @todo: Add commit message check # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" From 67da9e0e85dd7880b2a0a1357f3dd0b09c383d39 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 15 Dec 2020 22:45:18 +0100 Subject: [PATCH 22/41] [ticket/16659] Add setup script for LDAP PHPBB3-16659 --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 574724383d..210203e640 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -163,6 +163,13 @@ jobs: run: | travis/setup-database.sh $DB $PHP_VERSION $NOTESTS $MYISAM + - name: Setup LDAP + env: + SLOWTESTS: ${{ matrix.SLOWTESTS }} + if: ${{ matrix.SLOWTESTS == 1 }} + run: | + travis/setup-ldap.sh $SLOWTESTS + - name: Phing sniff env: DB: ${{steps.database-type.outputs.db}} From 2a1a22dffe7ad00f76015c2d903809197d0b81b0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 16:51:46 +0100 Subject: [PATCH 23/41] [ticket/16659] Adjust slapd setup for apparmor configuration PHPBB3-16659 --- .github/workflows/tests.yml | 2 +- travis/ldap/slapd.conf | 6 +++--- travis/setup-ldap.sh | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 210203e640..88ac480518 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv + 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 diff --git a/travis/ldap/slapd.conf b/travis/ldap/slapd.conf index 5fce95cee2..9f6aa980f7 100644 --- a/travis/ldap/slapd.conf +++ b/travis/ldap/slapd.conf @@ -4,13 +4,13 @@ include /etc/ldap/schema/cosine.schema include /etc/ldap/schema/inetorgperson.schema include /etc/ldap/schema/nis.schema -pidfile /tmp/slapd/slapd.pid -argsfile /tmp/slapd/slapd.args +pidfile /var/tmp/slapd/slapd.pid +argsfile /var/tmp/slapd/slapd.args modulepath /usr/lib/openldap database ldif -directory /tmp/slapd +directory /var/tmp/slapd suffix "dc=example,dc=com" rootdn "cn=admin,dc=example,dc=com" diff --git a/travis/setup-ldap.sh b/travis/setup-ldap.sh index 9be816d77d..a5cbd3c0e1 100755 --- a/travis/setup-ldap.sh +++ b/travis/setup-ldap.sh @@ -15,9 +15,10 @@ SLOWTESTS=$1 if [ "$SLOWTESTS" == '1' ] then - sudo apt-get -y install ldap-utils slapd php-ldap - mkdir /tmp/slapd - slapd -f travis/ldap/slapd.conf -h ldap://localhost:3389 & + sudo apt-get -y install ldap-utils slapd + mkdir /var/tmp/slapd + cp travis/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 travis/ldap/base.ldif fi From e0c5c0047d423d8d555b7cabf00b81ea85513b28 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 17:41:26 +0100 Subject: [PATCH 24/41] [ticket/16659] Enable notests tests with commit message check PHPBB3-16659 --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 88ac480518..1efaf77148 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,9 +17,9 @@ jobs: strategy: matrix: include: -# - php: '7.1' -# db: "none" -# NOTESTS: 1 + - php: '7.1' + db: "none" + NOTESTS: 1 # - php: '7.1' # db: "mariadb:10.1" # - php: '7.1' From 452f2cd08607de5345e5bb6504d1cb28935b205a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 17:48:55 +0100 Subject: [PATCH 25/41] [ticket/16659] Enable all items in build matrix PHPBB3-16659 --- .github/workflows/tests.yml | 88 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1efaf77148..e01cddfdf4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,51 +20,54 @@ jobs: - php: '7.1' db: "none" NOTESTS: 1 -# - 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: "postgres:9.5" -# - 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.1' -# db: "sqlite3" + - 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: "postgres:9.5" + - 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.1' + db: "sqlite3" - php: '7.1' db: "mysql:5.6" SLOWTESTS: 1 -# - php: '7.1' -# db: "mysql:5.6" -# MYISAM: 1 -# - php: '7.1' -# db: "mysql:5.7" + - php: '7.1' + db: "mysql:5.6" + MYISAM: 1 + - php: '7.1' + db: "mysql:5.7" - php: '7.2' db: "mcr.microsoft.com/mssql/server:2017-latest" db_alias: 'MSSQL 2017' -# - php: '7.2' -# db: "mysql:5.7" -# - php: '7.3' -# db: "mysql:5.7" -# - php: '7.4' -# db: "mysql:5.7" -# - php: '7.4' -# db: "mysql:8.0" -# - php: '8.0' -# db: "mysql:5.7" -# - php: '8.1' -# db: "mysql:5.7" + - php: '7.2' + db: "mcr.microsoft.com/mssql/server:2019-latest" + db_alias: 'MSSQL 2019' + - 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 }} @@ -231,10 +234,3 @@ jobs: if: ${{ matrix.NOTESTS == 1 && 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 - # @todo: Add commit message check - - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md - - # - name: Run test suite - # run: composer run-script test From b3e3d9642e1df3169079562a5adb2f0d1f6e57da Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 20:01:34 +0100 Subject: [PATCH 26/41] [ticket/16659] Add missing postgres test and improve naming PHPBB3-16659 --- .github/workflows/tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e01cddfdf4..c976ffa360 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,8 @@ jobs: db: "mariadb:10.5" - php: '7.1' db: "postgres:9.5" + - php: '7.1' + db: "postgres:9.6" - php: '7.1' db: "postgres:10" - php: '7.1' @@ -44,10 +46,14 @@ jobs: db: "sqlite3" - 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' From ef22a029b25e0bf986c9fccc2c83cef665a1dfbf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 21:46:57 +0100 Subject: [PATCH 27/41] [ticket/16659] Split up tests for each database type PHPBB3-16659 --- .github/check-doctum-parse-errors.sh | 26 +++ .github/check-executable-files.sh | 63 ++++++ .github/check-image-icc-profiles.sh | 14 ++ .github/ldap/base.ldif | 41 ++++ .github/ldap/slapd.conf | 17 ++ .github/phing-sniff.sh | 16 ++ .github/phpunit-mariadb-github.xml | 39 ++++ .github/phpunit-mssql-github.xml | 41 ++++ .github/phpunit-mysql-github.xml | 41 ++++ .github/phpunit-postgres-github.xml | 41 ++++ .github/phpunit-sqlite3-github.xml | 41 ++++ .github/setup-database.sh | 26 +++ .github/setup-exiftool.sh | 14 ++ .github/setup-ldap.sh | 19 ++ .github/setup-phpbb.sh | 36 +++ .github/setup-unbuffer.sh | 14 ++ .github/setup-webserver.sh | 81 +++++++ .github/workflows/tests.yml | 314 +++++++++++++++++++-------- 18 files changed, 789 insertions(+), 95 deletions(-) create mode 100755 .github/check-doctum-parse-errors.sh create mode 100755 .github/check-executable-files.sh create mode 100755 .github/check-image-icc-profiles.sh create mode 100644 .github/ldap/base.ldif create mode 100644 .github/ldap/slapd.conf create mode 100755 .github/phing-sniff.sh create mode 100644 .github/phpunit-mariadb-github.xml create mode 100644 .github/phpunit-mssql-github.xml create mode 100644 .github/phpunit-mysql-github.xml create mode 100644 .github/phpunit-postgres-github.xml create mode 100644 .github/phpunit-sqlite3-github.xml create mode 100755 .github/setup-database.sh create mode 100755 .github/setup-exiftool.sh create mode 100755 .github/setup-ldap.sh create mode 100755 .github/setup-phpbb.sh create mode 100755 .github/setup-unbuffer.sh create mode 100755 .github/setup-webserver.sh 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/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-sqlite3-github.xml b/.github/phpunit-sqlite3-github.xml new file mode 100644 index 0000000000..f5b2b67b22 --- /dev/null +++ b/.github/phpunit-sqlite3-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + 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 index c976ffa360..5ecac57913 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,14 +12,67 @@ on: - master jobs: - unit-tests: + # Basic checks, e.g. parse errors, commit messages, etc. + basic-checks: runs-on: ubuntu-18.04 strategy: matrix: include: - - php: '7.1' - db: "none" + - 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' @@ -30,20 +83,6 @@ jobs: db: "mariadb:10.4" - php: '7.1' db: "mariadb:10.5" - - 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.1' - db: "sqlite3" - php: '7.1' db: "mysql:5.6" db_alias: "MySQL Slow Tests" @@ -56,12 +95,6 @@ jobs: db: "mysql:5.6" - php: '7.1' db: "mysql:5.7" - - 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.2' db: "mysql:5.7" - php: '7.3' @@ -79,7 +112,7 @@ jobs: services: mysql: - image: ${{ matrix.db != 'mysql:5.6' && matrix.db != 'mysql:5.7' && matrix.db != 'mysql:8.0' && matrix.db != 'mariadb:10.1' && matrix.db != 'mariadb:10.2' && matrix.db != 'mariadb:10.3' && matrix.db != 'mariadb:10.4' && matrix.db != 'mariadb:10.5' && 'mysql:5.7' || matrix.db }} + image: ${{ matrix.db }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: phpbb_tests @@ -91,6 +124,95 @@ jobs: --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: @@ -106,6 +228,74 @@ jobs: --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: @@ -158,85 +348,19 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - MYSQL8: ${{ matrix.db }} == 'mysql:8.0' + NOTESTS: '0' run: | - travis/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} + .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} - name: Setup database env: DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} + MYISAM: '0' run: | - travis/setup-database.sh $DB $PHP_VERSION $NOTESTS $MYISAM - - - name: Setup LDAP - env: - SLOWTESTS: ${{ matrix.SLOWTESTS }} - if: ${{ matrix.SLOWTESTS == 1 }} - run: | - travis/setup-ldap.sh $SLOWTESTS - - - name: Phing sniff - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/phing-sniff.sh $DB $PHP_VERSION $NOTESTS - - - name: Check doctum parse errors - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-doctum-parse-errors.sh $DB $PHP_VERSION $NOTESTS - - - name: Check image ICC profiles - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-image-icc-profiles.sh $DB $PHP_VERSION $NOTESTS - - - name: Check executable files - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-executable-files.sh $DB $PHP_VERSION $NOTESTS ./ - - - name: Lint tests - if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }} - run: phpBB/vendor/bin/phpunit tests/lint_test.php + .github/setup-database.sh $DB $MYISAM - name: Run unit tests env: DB: ${{steps.database-type.outputs.db}} - if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }} run: | - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.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 travis/phpunit-$DB-travis.xml --group slow - - - name: Check commit message - env: - BRANCH: ${{ github.event.pull_request.base.ref }} - PR_SHA: ${{ github.event.pull_request.head.sha }} - if: ${{ matrix.NOTESTS == 1 && 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 + phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error From a1b994a8cd12f3988aa68ee919eb76e17945ab97 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 18 Dec 2020 22:26:51 +0100 Subject: [PATCH 28/41] [ticket/16659] Add scripts for ext preparation and sniffing PHPBB3-16659 --- .github/ext-sniff.sh | 25 +++++++++++++++++++++++++ .github/prepare-extension.sh | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 .github/ext-sniff.sh create mode 100755 .github/prepare-extension.sh 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/prepare-extension.sh b/.github/prepare-extension.sh new file mode 100755 index 0000000000..9a1eee43c6 --- /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 extensions .github/phpunit-*-travis.xml files in place +cp -R .github/*.xml phpBB/ext/$EXTNAME/.github +cp -R .github/*.sh phpBB/ext/$EXTNAME/.github From 9762cbf94f2ee037733eebc00841ab9b390ec1f5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Dec 2020 21:32:38 +0100 Subject: [PATCH 29/41] [ticket/16659] Remove test branch from build branches PHPBB3-16659 --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ecac57913..7354711a67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,6 @@ on: branches: - 3.3.x - master - - task/github-actions pull_request: branches: - 3.3.x From 8536c437c4c396e029d851cb1074e9239dee4401 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Dec 2020 21:41:54 +0100 Subject: [PATCH 30/41] [ticket/16659] Undo changes to travis folder Github actions are using their own scripts etc. PHPBB3-16659 --- travis/ldap/slapd.conf | 6 +-- travis/phpunit-mssql-travis.xml | 41 ------------------- ...l-travis.xml => phpunit-mysqli-travis.xml} | 0 travis/phpunit-postgres-travis.xml | 2 +- travis/setup-database.sh | 10 +++-- travis/setup-ldap.sh | 7 ++-- travis/setup-phpbb.sh | 10 +++++ travis/setup-webserver.sh | 21 ++-------- 8 files changed, 27 insertions(+), 70 deletions(-) delete mode 100644 travis/phpunit-mssql-travis.xml rename travis/{phpunit-mysql-travis.xml => phpunit-mysqli-travis.xml} (100%) diff --git a/travis/ldap/slapd.conf b/travis/ldap/slapd.conf index 9f6aa980f7..5fce95cee2 100644 --- a/travis/ldap/slapd.conf +++ b/travis/ldap/slapd.conf @@ -4,13 +4,13 @@ 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 +pidfile /tmp/slapd/slapd.pid +argsfile /tmp/slapd/slapd.args modulepath /usr/lib/openldap database ldif -directory /var/tmp/slapd +directory /tmp/slapd suffix "dc=example,dc=com" rootdn "cn=admin,dc=example,dc=com" diff --git a/travis/phpunit-mssql-travis.xml b/travis/phpunit-mssql-travis.xml deleted file mode 100644 index 37c1deae2d..0000000000 --- a/travis/phpunit-mssql-travis.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - ../tests - ../tests/functional - ../tests/lint_test.php - - - ../tests/functional - - - - - - slow - - - - - - - - - - - - - - - - diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysqli-travis.xml similarity index 100% rename from travis/phpunit-mysql-travis.xml rename to travis/phpunit-mysqli-travis.xml diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 2648f27bef..3d8376bda1 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -32,7 +32,7 @@ - + diff --git a/travis/setup-database.sh b/travis/setup-database.sh index 479e17f592..b581ddfccb 100755 --- a/travis/setup-database.sh +++ b/travis/setup-database.sh @@ -14,7 +14,6 @@ set -x DB=$1 TRAVIS_PHP_VERSION=$2 NOTESTS=$3 -MYISAM=$4 if [ "$NOTESTS" == '1' ] then @@ -27,7 +26,12 @@ then psql -c 'create database phpbb_tests;' -U postgres fi -if [ "$MYISAM" == '1' ] +if [ "$TRAVIS_PHP_VERSION" == "5.6" -a "$DB" == "mysqli" ] then - mysql -h 127.0.0.1 -u root -e 'SET GLOBAL storage_engine=MyISAM;' + mysql -e 'SET GLOBAL storage_engine=MyISAM;' +fi + +if [ "$DB" == "mysqli" -o "$DB" == "mariadb" ] +then + mysql -e 'create database IF NOT EXISTS phpbb_tests;' fi diff --git a/travis/setup-ldap.sh b/travis/setup-ldap.sh index a5cbd3c0e1..9be816d77d 100755 --- a/travis/setup-ldap.sh +++ b/travis/setup-ldap.sh @@ -15,10 +15,9 @@ SLOWTESTS=$1 if [ "$SLOWTESTS" == '1' ] then - sudo apt-get -y install ldap-utils slapd - mkdir /var/tmp/slapd - cp travis/ldap/slapd.conf /var/tmp/slapd/slapd.conf - slapd -d 256 -d 128 -f /var/tmp/slapd/slapd.conf -h ldap://localhost:3389 & + sudo apt-get -y install ldap-utils slapd php-ldap + mkdir /tmp/slapd + slapd -f travis/ldap/slapd.conf -h ldap://localhost:3389 & sleep 3 ldapadd -h localhost:3389 -D "cn=admin,dc=example,dc=com" -w adminadmin -f travis/ldap/base.ldif fi diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index a6e51b5ed9..208b715dfe 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -22,11 +22,21 @@ then travis/setup-unbuffer.sh fi +if [ "$DB" == "mariadb" ] +then + travis/setup-mariadb.sh +fi + if [ "$MYSQL8" == '1' ] then travis/setup-mysql8.sh fi +if [ "$NOTESTS" != '1' ] +then + travis/setup-php-extensions.sh +fi + if [ "$NOTESTS" != '1' ] then travis/setup-webserver.sh diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index af6fccfe53..68bcd6ac00 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -12,7 +12,7 @@ set -e set -x sudo apt-get update -sudo apt-get install -y nginx coreutils +sudo apt-get install -y nginx realpath sudo service nginx stop @@ -25,28 +25,13 @@ 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_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm" 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-dom \ - 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] + [travis] user = $USER group = $USER listen = $APP_SOCK From 8013bb369ac934d3049b37d98c6b2ddd09df00d1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Dec 2020 21:43:36 +0100 Subject: [PATCH 31/41] [ticket/16659] Build PR branch to show that CI is working PHPBB3-16659 --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7354711a67..74cc3f8e4e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,6 +5,7 @@ on: branches: - 3.3.x - master + - ticket/16659 pull_request: branches: - 3.3.x From 23caeec1cf230409e6e2f8dcb301357d89153925 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Dec 2020 22:21:03 +0100 Subject: [PATCH 32/41] [ticket/16661] Add build badge and remove PR branch from builds PHPBB3-16661 --- .github/workflows/tests.yml | 1 - README.md | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 74cc3f8e4e..7354711a67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,6 @@ on: branches: - 3.3.x - master - - ticket/16659 pull_request: branches: - 3.3.x diff --git a/README.md b/README.md index 1cb10c664b..6fd6c9cbef 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 | AppVeyor +------- | ----------- | -------------- | -------- +**master** | Latest development version | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=master) | [![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 | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=3.3.x) | [![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) ## 📜 License From f67e2b9fe029251eb7753d77e3939ba9c7a1ecf4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Dec 2020 22:23:23 +0100 Subject: [PATCH 33/41] [ticket/16661] Stop building on travis CI PHPBB3-16661 --- .travis.yml | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 .travis.yml 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" From 97ddf7e0086a76fa84a5908343a00941c5562ea4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Dec 2020 22:26:53 +0100 Subject: [PATCH 34/41] [ticket/16661] Add check executable files for extensions Also added some minor code adjustments. PHPBB3-16661 --- .github/ext-check-executable-files.sh | 64 +++++++++++++++++++++++++++ .github/phpunit-sqlite3-github.xml | 6 --- .github/prepare-extension.sh | 2 +- 3 files changed, 65 insertions(+), 7 deletions(-) create mode 100755 .github/ext-check-executable-files.sh diff --git a/.github/ext-check-executable-files.sh b/.github/ext-check-executable-files.sh new file mode 100755 index 0000000000..affcfa03cc --- /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" + +# 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/phpunit-sqlite3-github.xml b/.github/phpunit-sqlite3-github.xml index f5b2b67b22..b079a0bbbe 100644 --- a/.github/phpunit-sqlite3-github.xml +++ b/.github/phpunit-sqlite3-github.xml @@ -27,12 +27,6 @@ - - - - - - diff --git a/.github/prepare-extension.sh b/.github/prepare-extension.sh index 9a1eee43c6..d3adc95ec5 100755 --- a/.github/prepare-extension.sh +++ b/.github/prepare-extension.sh @@ -17,6 +17,6 @@ EXTNAME=$1 mkdir --parents phpBB/ext/$EXTNAME cp -R ../tmp/* phpBB/ext/$EXTNAME -# Move the extensions .github/phpunit-*-travis.xml files in place +# Move the test files for extensions in place cp -R .github/*.xml phpBB/ext/$EXTNAME/.github cp -R .github/*.sh phpBB/ext/$EXTNAME/.github From 1b2819065aea017bc3d8553aa626b773cfbb240d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Dec 2020 21:13:58 +0100 Subject: [PATCH 35/41] [ticket/16661] Remove Appveyor builds PHPBB3-16661 --- .appveyor.yml | 144 -------------------------------------------------- README.md | 8 +-- 2 files changed, 4 insertions(+), 148 deletions(-) delete mode 100644 .appveyor.yml 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/README.md b/README.md index 6fd6c9cbef..277763c582 100644 --- a/README.md +++ b/README.md @@ -37,10 +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 | Github Actions | AppVeyor -------- | ----------- | -------------- | -------- -**master** | Latest development version | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=master) | [![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 | ![Tests](https://github.com/phpbb/phpbb/workflows/Tests/badge.svg?branch=3.3.x) | [![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) +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 From 8992277ce8acf9aaf779c3248337ba1348fed6d6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Dec 2020 21:17:24 +0100 Subject: [PATCH 36/41] [ticket/16661] Exclude extension .git directory in executable check PHPBB3-16661 --- .github/ext-check-executable-files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ext-check-executable-files.sh b/.github/ext-check-executable-files.sh index affcfa03cc..09db25d40b 100755 --- a/.github/ext-check-executable-files.sh +++ b/.github/ext-check-executable-files.sh @@ -18,7 +18,7 @@ path="${root}phpBB/ext/${extname}/" # The following variables MUST NOT contain any wildcard # Directories to skip -directories_skipped="-path ${path}develop -o -path ${path}vendor" +directories_skipped="-path ${path}develop -o -path ${path}vendor -o -path ${path}.git" # Files to skip files_skipped="-false" From d6427e777c6208485714db08902088e73459088d Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 24 Dec 2020 00:04:36 +0100 Subject: [PATCH 37/41] [ticket/16665] Fix Emoji for strings in board settings PHPBB3-16665 --- phpBB/includes/acp/acp_board.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 968c9762cc..9001459928 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -582,7 +582,20 @@ class acp_board continue; } - $config->set($config_name, $config_value); + $config_name_ary = ['sitename', 'site_desc', 'site_home_text', 'board_index_text', 'board_disable_msg']; + + 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'])) { From c37e8ae8b9754e70f8bb38db5c95b6fd29179a32 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 24 Dec 2020 05:27:12 +0100 Subject: [PATCH 38/41] [ticket/16665] Fix Emoji for strings in board settings Add event PHPBB3-16665 --- phpBB/includes/acp/acp_board.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 9001459928..9f89bd74cf 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -584,6 +584,16 @@ class acp_board $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)) { /** From 9db70086dd19d02d4010b996b79e69d328694c03 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 27 Dec 2020 19:19:37 +0100 Subject: [PATCH 39/41] [ticket/16661] Add test for phpBB on Windows PHPBB3-16661 --- .github/phpunit-psql-windows-github.xml | 41 ++++++++++++ .github/workflows/tests.yml | 83 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 .github/phpunit-psql-windows-github.xml 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/workflows/tests.yml b/.github/workflows/tests.yml index 7354711a67..9d45991111 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -363,3 +363,86 @@ jobs: 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 From 94f9a5342a2946a908889ce09c41dd7065b4047a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Tue, 29 Dec 2020 17:48:06 +0100 Subject: [PATCH 40/41] [ticket/16667] Remove unused installer task PHPBB3-16667 --- .../install_database/task/create_schema.php | 227 ------------------ 1 file changed, 227 deletions(-) delete mode 100644 phpBB/phpbb/install/module/install_database/task/create_schema.php 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'; - } -} From f95802c2117f6e3f9909868a2e4482ff441b2d19 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 29 Dec 2020 20:53:57 +0100 Subject: [PATCH 41/41] [ticket/16665] Fix Emoji for strings in board settings PHPBB3-16665 --- phpBB/includes/acp/acp_board.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 9f89bd74cf..e22d493a0f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -582,7 +582,14 @@ class acp_board continue; } - $config_name_ary = ['sitename', 'site_desc', 'site_home_text', 'board_index_text', 'board_disable_msg']; + // 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