From 16591077ace2be482f0442924e0f55c3741d1f13 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 19 Aug 2020 12:28:34 +0200 Subject: [PATCH] Fix Database $_SERVER usage and remove old .travis files --- .github/workflows/php.yml | 21 ++++++----------- .travis.yml | 31 -------------------------- .travis/apcu.ini | 4 ---- .travis/memcached.ini | 1 - .travis/redis.ini | 1 - src/Database/Database.php | 4 ++-- tests/Util/Database/StaticDatabase.php | 2 +- 7 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 .travis.yml delete mode 100644 .travis/apcu.ini delete mode 100644 .travis/memcached.ini delete mode 100644 .travis/redis.ini diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3da7ee879..c905ee877 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -5,20 +5,14 @@ jobs: friendica: name: Friendica (PHP ${{ matrix.php-versions }}) runs-on: ubuntu-latest - env: - MYSQL_HOST: localhost - MYSQL_PORT: 3306 - MYSQL_DATABASE: test - MYSQL_PASSWORD: "" - MYSQL_USERNAME: travis services: mariadb: image: mariadb:latest env: MYSQL_ALLOW_EMPTY_PASSWORD: true MYSQL_DATABASE: test - MYSQL_PASSWORD: "" - MYSQL_USERNAME: travis + MYSQL_PASSWORD: test + MYSQL_USER: test ports: - 3306/tcp options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 @@ -83,8 +77,7 @@ jobs: env: PORT: ${{ job.services.mariadb.ports[3306] }} run: | - mysql -h"127.0.0.1" -P"$PORT" -uroot -e 'CREATE DATABASE IF NOT EXISTS test;' - mysql -h"127.0.0.1" -P"$PORT" -uroot test < database.sql + mysql -h"127.0.0.1" -P"$PORT" -utest -ptest test < database.sql - name: Test with Parallel-lint run: vendor/bin/parallel-lint --exclude vendor/ --exclude view/asset/ . @@ -92,11 +85,11 @@ jobs: - name: Test with phpunit run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml env: - MYSQL_HOST: localhost - MYSQL_PORT: 3306 + MYSQL_HOST: 127.0.0.1 + MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} MYSQL_DATABASE: test - MYSQL_PASSWORD: "" - MYSQL_USERNAME: root + MYSQL_PASSWORD: test + MYSQL_USER: test - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5e4c3483b..000000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -language: php -## Friendica officially supports PHP version >= 7.1 -php: - - 7.1 - - 7.2 - - 7.3 - -services: - - mysql - - redis - - memcached -env: - - MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USERNAME=travis MYSQL_PASSWORD="" MYSQL_DATABASE=test - -install: - - composer install -before_script: - - cp config/local-sample.config.php config/local.config.php - - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' - - mysql -utravis test < database.sql - - pecl channel-update pecl.php.net - - pecl config-set preferred_state beta - - phpenv config-add .travis/redis.ini - - phpenv config-add .travis/memcached.ini - -script: - - vendor/bin/parallel-lint --exclude vendor/ --exclude view/asset/ . - - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml - -after_success: bash <(curl -s https://codecov.io/bash) diff --git a/.travis/apcu.ini b/.travis/apcu.ini deleted file mode 100644 index 92598662c..000000000 --- a/.travis/apcu.ini +++ /dev/null @@ -1,4 +0,0 @@ -extension="apcu.so" - -apc.enabled = 1 -apc.enable_cli = 1 \ No newline at end of file diff --git a/.travis/memcached.ini b/.travis/memcached.ini deleted file mode 100644 index c9a2ff0c9..000000000 --- a/.travis/memcached.ini +++ /dev/null @@ -1 +0,0 @@ -extension="memcached.so" \ No newline at end of file diff --git a/.travis/redis.ini b/.travis/redis.ini deleted file mode 100644 index ab995b837..000000000 --- a/.travis/redis.ini +++ /dev/null @@ -1 +0,0 @@ -extension="redis.so" \ No newline at end of file diff --git a/src/Database/Database.php b/src/Database/Database.php index 0b38c24ba..4b96205a9 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -59,7 +59,7 @@ class Database /** @var PDO|mysqli */ protected $connection; protected $driver; - private $emulate_prepares = false; + protected $emulate_prepares = false; private $error = false; private $errorno = 0; private $affected_rows = 0; @@ -88,7 +88,7 @@ class Database { // Use environment variables for mysql if they are set beforehand if (!empty($server['MYSQL_HOST']) - && (!empty($server['MYSQL_USERNAME'] || !empty($server['MYSQL_USER']))) + && (!empty($server['MYSQL_USERNAME']) || !empty($server['MYSQL_USER'])) && $server['MYSQL_PASSWORD'] !== false && !empty($server['MYSQL_DATABASE'])) { diff --git a/tests/Util/Database/StaticDatabase.php b/tests/Util/Database/StaticDatabase.php index c95b690c6..73a142d9a 100644 --- a/tests/Util/Database/StaticDatabase.php +++ b/tests/Util/Database/StaticDatabase.php @@ -101,7 +101,7 @@ class StaticDatabase extends Database { // Use environment variables for mysql if they are set beforehand if (!empty($server['MYSQL_HOST']) - && (!empty($server['MYSQL_USERNAME'] || !empty($server['MYSQL_USER']))) + && (!empty($server['MYSQL_USERNAME']) || !empty($server['MYSQL_USER'])) && $server['MYSQL_PASSWORD'] !== false && !empty($server['MYSQL_DATABASE'])) {