From 1157380c8749b666a97b8e97d02789bd3450797e Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 12:26:32 +0200 Subject: [PATCH 01/22] Add PHP 8.4, drop unsupported PHP versions Dropped MySQL 5.7 --- .env.mysql | 4 + .github/workflows/tests.yml | 52 ++------ Dockerfile | 29 ++--- README.md | 28 ++--- compose.yaml | 82 +++++-------- composer.json | 6 +- docker-entrypoint-initdb.d/mariadb-init.sql | 30 +++++ docker-entrypoint-initdb.d/mysql-8.0-init.sql | 30 +++++ tests/scripts/create_users.sh | 50 -------- tests/scripts/pdo_checks.php | 5 +- tests/scripts/test.php | 113 ++++++++++++------ tests/scripts/test.sh | 7 +- tests/scripts/test001.src.sql | 4 +- tests/scripts/test006.src.sql | 4 +- tests/scripts/test010.8.src.sql | 2 +- tests/scripts/test010.src.sql | 2 +- 16 files changed, 212 insertions(+), 236 deletions(-) create mode 100644 .env.mysql create mode 100644 docker-entrypoint-initdb.d/mariadb-init.sql create mode 100644 docker-entrypoint-initdb.d/mysql-8.0-init.sql delete mode 100755 tests/scripts/create_users.sh diff --git a/.env.mysql b/.env.mysql new file mode 100644 index 00000000..27eb068f --- /dev/null +++ b/.env.mysql @@ -0,0 +1,4 @@ +MYSQL_ROOT_PASSWORD=mysql +MYSQL_DATABASE=mysql +MYSQL_USER=mysql +MYSQL_PASSWORD=mysql diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c832731b..3eccba95 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,6 +5,7 @@ on: branches: # Push events on main branch - main + - php-8.4 pull_request: jobs: @@ -17,36 +18,7 @@ jobs: fail-fast: false matrix: include: - # MySQL 5.7 - - os: ubuntu-20.04 - database: 'mysql' - database-version: '5.7' - php-version: '7.4' - - os: ubuntu-20.04 - database: 'mysql' - database-version: '5.7' - php-version: '8.0' - - os: ubuntu-20.04 - database: 'mysql' - database-version: '5.7' - php-version: '8.1' - - os: ubuntu-20.04 - database: 'mysql' - database-version: '5.7' - php-version: '8.2' - - os: ubuntu-20.04 - database: 'mysql' - database-version: '5.7' - php-version: '8.3' # MySQL 8.0 - - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '7.4' - - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '8.0' - os: ubuntu-latest database: 'mysql' database-version: '8.0' @@ -59,15 +31,11 @@ jobs: database: 'mysql' database-version: '8.0' php-version: '8.3' + - os: ubuntu-latest + database: 'mysql' + database-version: '8.0' + php-version: '8.4' # MariaDB 10.11 LTS - - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '7.4' - - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '8.0' - os: ubuntu-20.04 database: 'mariadb' database-version: '10.11' @@ -80,6 +48,10 @@ jobs: database: 'mariadb' database-version: '10.11' php-version: '8.3' + - os: ubuntu-20.04 + database: 'mariadb' + database-version: '10.11' + php-version: '8.4' steps: @@ -87,9 +59,9 @@ jobs: with: distribution: '${{ matrix.database }}' mysql-version: '${{ matrix.database-version }}' - user: 'travis' - password: '' - root-password: 'drupal' + user: 'example' + password: 'example' + root-password: 'example' - name: Checkout code uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index 9ff91d93..b088fcf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,14 @@ -ARG PHP_SHORT_VERSION +ARG PHP_SHORT_VERSION=81 -FROM druidfi/php:7.4 AS php-74 - -RUN sudo apk --update -X https://dl-cdn.alpinelinux.org/alpine/edge/testing --no-cache add php7-pdo php7-pdo_mysql - -FROM druidfi/php:8.0 AS php-80 - -RUN sudo apk --update --no-cache add php8-pdo php8-pdo_mysql - -FROM druidfi/php:8.1 AS php-81 - -RUN sudo apk --update --no-cache add php81-pdo php81-pdo_mysql - -FROM druidfi/php:8.2 AS php-82 - -RUN sudo apk --update -X https://dl-cdn.alpinelinux.org/alpine/edge/community --no-cache add php82-pdo php82-pdo_mysql - -FROM druidfi/php:8.3 AS php-83 - -RUN sudo apk --update -X https://dl-cdn.alpinelinux.org/alpine/edge/community --no-cache add php83-pdo php83-pdo_mysql +FROM php:8.1-alpine AS php-81 +FROM php:8.2-alpine AS php-82 +FROM php:8.3-alpine AS php-83 +FROM php:8.4-alpine AS php-84 FROM php-${PHP_SHORT_VERSION} -RUN sudo apk --update --no-cache add bash mysql-client \ - && sudo rm -rf /var/cache/apk/* +RUN docker-php-ext-install pdo pdo_mysql +RUN apk --update --no-cache add bash mysql-client WORKDIR /app diff --git a/README.md b/README.md index e6e8b51b..5c6d4a85 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ Out of the box, `mysqldump-php` supports backing up table structures, the data i ## Requirements -- PHP 7.4 or 8.x with PDO - [see supported versions](https://www.php.net/supported-versions.php) -- MySQL 5.7 or newer (and compatible MariaDB) +- PHP 8.1 or newer with PDO - [see supported versions](https://www.php.net/supported-versions.php) +- MySQL 8.0 or newer (and compatible MariaDB) ## Installing Install using [Composer](https://getcomposer.org/): -``` +```console composer require druidfi/mysqldump-php ``` @@ -239,29 +239,19 @@ Local setup for tests: ```console docker compose up --wait --build -docker compose exec php81 /app/tests/scripts/create_users.sh -docker compose exec php81 /app/tests/scripts/create_users.sh db2 -docker compose exec php81 /app/tests/scripts/create_users.sh db3 -docker compose exec -w /app/tests/scripts php74 ./test.sh -docker compose exec -w /app/tests/scripts php80 ./test.sh -docker compose exec -w /app/tests/scripts php81 ./test.sh -docker compose exec -w /app/tests/scripts php82 ./test.sh -docker compose exec -w /app/tests/scripts php83 ./test.sh -docker compose exec -w /app/tests/scripts php74 ./test.sh db2 -docker compose exec -w /app/tests/scripts php80 ./test.sh db2 +docker compose exec -w /app/tests/scripts php81 ./test.sh db1 +docker compose exec -w /app/tests/scripts php82 ./test.sh db1 +docker compose exec -w /app/tests/scripts php83 ./test.sh db1 +docker compose exec -w /app/tests/scripts php84 ./test.sh db1 docker compose exec -w /app/tests/scripts php81 ./test.sh db2 docker compose exec -w /app/tests/scripts php82 ./test.sh db2 docker compose exec -w /app/tests/scripts php83 ./test.sh db2 -docker compose exec -w /app/tests/scripts php74 ./test.sh db3 -docker compose exec -w /app/tests/scripts php80 ./test.sh db3 -docker compose exec -w /app/tests/scripts php81 ./test.sh db3 -docker compose exec -w /app/tests/scripts php82 ./test.sh db3 -docker compose exec -w /app/tests/scripts php83 ./test.sh db3 +docker compose exec -w /app/tests/scripts php84 ./test.sh db2 ``` ## Credits -Forked from Diego Torres's version which have latest updates from 2020. Use it for PHP 7.3 and older. +Forked from Diego Torres's version which have latest updates from 2020. Use it for PHP 8.0 and older. https://github.com/ifsnop/mysqldump-php Originally based on James Elliott's script from 2009. diff --git a/compose.yaml b/compose.yaml index 2a9b3452..3d074b3b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,91 +1,65 @@ -version: '3.7' - services: - db: - container_name: mysqldump-php-mysql-57 - image: druidfi/mysql:5.7-drupal - ports: - - 3306 - - db2: + db1: container_name: mysqldump-php-mysql-80 - image: druidfi/mysql:8.0-drupal - ports: - - 3306 - - db3: - container_name: mysqldump-php-mariadb-80 - image: druidfi/mariadb:10.11-drupal - ports: - - 3306 + image: mysql:8.0 + env_file: + - .env.mysql + volumes: + - ./docker-entrypoint-initdb.d/mysql-8.0-init.sql:/docker-entrypoint-initdb.d/00-init.sql - php74: - container_name: mysqldump-php-74 - image: mysqldump-php-tester:php-7.4 - build: - context: . - args: - PHP_SHORT_VERSION: "74" + db2: + container_name: mysqldump-php-mariadb-10 + image: mariadb:10.11 + env_file: + - .env.mysql volumes: - - .:/app - depends_on: - - db - - db2 - - db3 + - ./docker-entrypoint-initdb.d/mariadb-init.sql:/docker-entrypoint-initdb.d/00-init.sql - php80: - container_name: mysqldump-php-80 - image: mysqldump-php-tester:php-8.0 + php81: + container_name: mysqldump-php-81 build: context: . args: - PHP_SHORT_VERSION: "80" + PHP_SHORT_VERSION: 81 volumes: - .:/app depends_on: - - db + - db1 - db2 - - db3 - php81: - container_name: mysqldump-php-81 - image: mysqldump-php-tester:php-8.1 + php82: + container_name: mysqldump-php-82 build: context: . args: - PHP_SHORT_VERSION: "81" + PHP_SHORT_VERSION: 82 volumes: - .:/app depends_on: - - db + - db1 - db2 - - db3 - php82: - container_name: mysqldump-php-82 - image: mysqldump-php-tester:php-8.2 + php83: + container_name: mysqldump-php-83 build: context: . args: - PHP_SHORT_VERSION: "82" + PHP_SHORT_VERSION: 83 volumes: - .:/app depends_on: - - db + - db1 - db2 - - db3 - php83: - container_name: mysqldump-php-83 - image: mysqldump-php-tester:php-8.3 + php84: + container_name: mysqldump-php-84 build: context: . args: - PHP_SHORT_VERSION: "83" + PHP_SHORT_VERSION: 84 volumes: - .:/app depends_on: - - db + - db1 - db2 - - db3 diff --git a/composer.json b/composer.json index dcbb9a28..100f3e26 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "druidfi/mysqldump-php", "description": "PHP version of mysqldump cli that comes with MySQL", "type": "library", - "keywords": ["mysql", "mysqldump", "pdo", "php7", "php8", "database", "php", "sql", "mariadb", "mysql-backup"], + "keywords": ["mysql", "mysqldump", "pdo", "php8", "database", "php", "sql", "mariadb", "mysql-backup"], "homepage": "https://github.com/druidfi/mysqldump-php", "license": "GPL-3.0-or-later", "minimum-stability": "stable", @@ -18,13 +18,13 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.1", "composer-runtime-api": "^2", "ext-pdo": "*" }, "require-dev": { "squizlabs/php_codesniffer": "3.*", - "phpunit/phpunit": "^8.5.15 || ^9" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { diff --git a/docker-entrypoint-initdb.d/mariadb-init.sql b/docker-entrypoint-initdb.d/mariadb-init.sql new file mode 100644 index 00000000..edfb5f3d --- /dev/null +++ b/docker-entrypoint-initdb.d/mariadb-init.sql @@ -0,0 +1,30 @@ +CREATE USER IF NOT EXISTS 'example'@'%' IDENTIFIED BY 'example'; +GRANT ALL ON *.* TO 'example'@'%'; + +CREATE DATABASE IF NOT EXISTS test001; +CREATE DATABASE IF NOT EXISTS test002; +CREATE DATABASE IF NOT EXISTS test005; +CREATE DATABASE IF NOT EXISTS test006a; +CREATE DATABASE IF NOT EXISTS test006b; +CREATE DATABASE IF NOT EXISTS test008; +CREATE DATABASE IF NOT EXISTS test009; +CREATE DATABASE IF NOT EXISTS test010; +CREATE DATABASE IF NOT EXISTS test011; +CREATE DATABASE IF NOT EXISTS test012; +CREATE DATABASE IF NOT EXISTS test014; +GRANT ALL PRIVILEGES ON test001.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test002.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test005.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test006a.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test006b.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test008.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test009.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test010.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test011.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test012.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test014.* TO 'example'@'%' WITH GRANT OPTION; +GRANT PROCESS,SUPER,LOCK TABLES ON *.* TO 'example'@'%'; + +FLUSH PRIVILEGES; + +SHOW databases; diff --git a/docker-entrypoint-initdb.d/mysql-8.0-init.sql b/docker-entrypoint-initdb.d/mysql-8.0-init.sql new file mode 100644 index 00000000..7c77a2d9 --- /dev/null +++ b/docker-entrypoint-initdb.d/mysql-8.0-init.sql @@ -0,0 +1,30 @@ +CREATE USER IF NOT EXISTS 'example'@'%' IDENTIFIED WITH mysql_native_password BY 'example'; +GRANT ALL ON *.* TO 'example'@'%'; + +CREATE DATABASE IF NOT EXISTS test001; +CREATE DATABASE IF NOT EXISTS test002; +CREATE DATABASE IF NOT EXISTS test005; +CREATE DATABASE IF NOT EXISTS test006a; +CREATE DATABASE IF NOT EXISTS test006b; +CREATE DATABASE IF NOT EXISTS test008; +CREATE DATABASE IF NOT EXISTS test009; +CREATE DATABASE IF NOT EXISTS test010; +CREATE DATABASE IF NOT EXISTS test011; +CREATE DATABASE IF NOT EXISTS test012; +CREATE DATABASE IF NOT EXISTS test014; +GRANT ALL PRIVILEGES ON test001.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test002.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test005.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test006a.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test006b.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test008.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test009.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test010.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test011.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test012.* TO 'example'@'%' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON test014.* TO 'example'@'%' WITH GRANT OPTION; +GRANT PROCESS,SUPER,LOCK TABLES ON *.* TO 'example'@'%'; + +FLUSH PRIVILEGES; + +SHOW databases; diff --git a/tests/scripts/create_users.sh b/tests/scripts/create_users.sh deleted file mode 100755 index 00abd601..00000000 --- a/tests/scripts/create_users.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -HOST=${1:-db} -MYSQL_ROOT_PASSWORD=drupal -MYSQL_CMD="mysql -h $HOST -u root -p$MYSQL_ROOT_PASSWORD" -USER=travis - -major=`$MYSQL_CMD -e "SELECT @@version\G" | grep version |awk '{print $2}' | awk -F"." '{print $1}'` -medium=`$MYSQL_CMD -e "SELECT @@version\G" | grep version |awk '{print $2}' | awk -F"." '{print $2}'` -minor=`$MYSQL_CMD -e "SELECT @@version\G" | grep version |awk '{print $2}' | awk -F"." '{print $3}'` - -printf "\nCreating users in MySQL server version $major.$medium.$minor on host '$HOST' with user '$USER'\n\n" - -$MYSQL_CMD -e "CREATE USER IF NOT EXISTS '$USER'@'%';" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test001;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test002;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test005;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test006a;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test006b;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test008;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test009;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test010;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test011;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test012;" -$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS test014;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test001.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test002.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test005.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test006a.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test006b.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test008.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test009.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test010.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test011.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test012.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT ALL PRIVILEGES ON test014.* TO '$USER'@'%' WITH GRANT OPTION;" -$MYSQL_CMD -e "GRANT PROCESS,SUPER,LOCK TABLES ON *.* TO '$USER'@'%';" - -if [[ $major -eq 5 && $medium -ge 7 ]]; then - $MYSQL_CMD -e "GRANT SELECT ON mysql.proc to '$USER'@'%';" -fi - -if [[ $major -eq 5 && $medium -ge 7 ]]; then - $MYSQL_CMD -e "use mysql; update user set authentication_string=PASSWORD('') where User='$USER'; update user set plugin='mysql_native_password';" -fi - -$MYSQL_CMD -e "FLUSH PRIVILEGES;" - -echo "Listing created databases with user '$USER'" -mysql -h $HOST -u $USER -e "SHOW databases;" diff --git a/tests/scripts/pdo_checks.php b/tests/scripts/pdo_checks.php index c9d11099..f6ed77be 100644 --- a/tests/scripts/pdo_checks.php +++ b/tests/scripts/pdo_checks.php @@ -4,14 +4,15 @@ error_reporting(E_ALL); $host = $argv[1] ?? 'db'; // Get host name from test.sh -$user = 'travis'; +$user = 'example'; +$pass = 'example'; $expected_double = '-2.2250738585072014e-308'; $ret = 0; print "PHP version is ". phpversion() . PHP_EOL; print "PDO check: double field" . PHP_EOL . PHP_EOL; -$db = new \PDO("mysql:host=$host;dbname=test001", $user, null, [ +$db = new \PDO("mysql:host=$host;dbname=test001", $user, $pass, [ \PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false, diff --git a/tests/scripts/test.php b/tests/scripts/test.php index 941c6247..de0896d4 100644 --- a/tests/scripts/test.php +++ b/tests/scripts/test.php @@ -10,10 +10,11 @@ use Druidfi\Mysqldump\Compress\CompressManagerFactory; $host = $argv[1] ?? 'db'; // Get host name from test.sh -$user = 'travis'; +$user = 'example'; +$pass = 'example'; $dumpSettings = [ - 'exclude-tables' => ['/^travis*/'], + 'exclude-tables' => ['/^example*/'], 'compress' => CompressManagerFactory::NONE, 'no-data' => false, 'add-drop-table' => true, @@ -29,153 +30,191 @@ 'add-drop-database' => false, 'hex-blob' => true, 'no-create-info' => false, - 'where' => '' + 'where' => '', ]; try { // do nothing test print "Create dump with PHP: mysql-php_test000.sql" . PHP_EOL; - $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user); + $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user, $pass); print "Create dump with PHP: mysql-php_test001.sql" . PHP_EOL; - $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user, "", $dumpSettings); + $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user, $pass, $dumpSettings); $dump->start("output/mysqldump-php_test001.sql"); // checks if complete-insert && hex-blob works ok together print "Create dump with PHP: mysql-php_test001_complete.sql" . PHP_EOL; $dumpSettings['complete-insert'] = true; - $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user, "", $dumpSettings); + $dump = new Mysqldump("mysql:host=$host;dbname=test001", $user, $pass, $dumpSettings); $dump->start("output/mysqldump-php_test001_complete.sql"); print "Create dump with PHP: mysql-php_test002.sql" . PHP_EOL; $dumpSettings['default-character-set'] = DumpSettings::UTF8MB4; $dumpSettings['complete-insert'] = true; - $dump = new Mysqldump("mysql:host=$host;dbname=test002", $user, "", $dumpSettings); + $dump = new Mysqldump("mysql:host=$host;dbname=test002", $user, $pass, $dumpSettings); $dump->start("output/mysqldump-php_test002.sql"); print "Create dump with PHP: mysql-php_test005.sql" . PHP_EOL; $dumpSettings['complete-insert'] = false; - $dump = new Mysqldump("mysql:host=$host;dbname=test005", $user, "", $dumpSettings); + $dump = new Mysqldump("mysql:host=$host;dbname=test005", $user, $pass, $dumpSettings); $dump->start("output/mysqldump-php_test005.sql"); print "Create dump with PHP: mysql-php_test006.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test006a", $user, - "", - ["no-data" => true, "add-drop-table" => true] + $pass, + [ + "no-data" => true, + "add-drop-table" => true, + ] ); + $dump->start("output/mysqldump-php_test006.sql"); print "Create dump with PHP: mysql-php_test008.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test008", $user, - "", - ["no-data" => true, "add-drop-table" => true] + $pass, + [ + "no-data" => true, + "add-drop-table" => true, + ] ); + $dump->start("output/mysqldump-php_test008.sql"); print "Create dump with PHP: mysql-php_test009.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test009", $user, - "", - ["no-data" => true, "add-drop-table" => true, "reset-auto-increment" => true, "add-drop-database" => true] + $pass, + [ + "no-data" => true, + "add-drop-table" => true, + "reset-auto-increment" => true, + "add-drop-database" => true, + ] ); + $dump->start("output/mysqldump-php_test009.sql"); print "Create dump with PHP: mysql-php_test010.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test010", $user, - "", - ["events" => true] + $pass, + [ + "events" => true, + ] ); + $dump->start("output/mysqldump-php_test010.sql"); print "Create dump with PHP: mysql-php_test011a.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test011", $user, - "", - ['complete-insert' => false] + $pass, + [ + 'complete-insert' => false, + ] ); + $dump->start("output/mysqldump-php_test011a.sql"); print "Create dump with PHP: mysql-php_test011b.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test011", $user, - "", + $pass, [ - 'complete-insert' => true, + 'complete-insert' => true, ] ); + $dump->start("output/mysqldump-php_test011b.sql"); print "Create dump with PHP: mysql-php_test012.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test012", $user, - "", + $pass, [ - 'events' => true, - 'skip-triggers' => false, - 'routines' => true, - 'add-drop-trigger' => true, + 'events' => true, + 'skip-triggers' => false, + 'routines' => true, + 'add-drop-trigger' => true, ] ); + $dump->start("output/mysqldump-php_test012.sql"); print "Create dump with PHP: mysql-php_test012b_no-definer.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test012", $user, - "", + $pass, [ - "events" => true, - 'skip-triggers' => false, - 'routines' => true, - 'add-drop-trigger' => true, - 'skip-definer' => true, + "events" => true, + 'skip-triggers' => false, + 'routines' => true, + 'add-drop-trigger' => true, + 'skip-definer' => true, ] ); + $dump->start("output/mysqldump-php_test012_no-definer.sql"); print "Create dump with PHP: mysql-php_test013.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test001", $user, - "", + $pass, [ - "insert-ignore" => true, - "extended-insert" => false + "insert-ignore" => true, + "extended-insert" => false, ] ); + $dump->start("output/mysqldump-php_test013.sql"); print "Create dump with PHP: mysql-php_test014a.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test014", $user, - "", + $pass, [ 'complete-insert' => false, 'hex-blob' => true, - ] ); + ] + ); + $dump->start("output/mysqldump-php_test014a.sql"); print "Create dump with PHP: mysql-php_test014b.sql" . PHP_EOL; + $dump = new Mysqldump( "mysql:host=$host;dbname=test014", $user, - "", + $pass, [ 'complete-insert' => true, 'hex-blob' => true, ] ); + $dump->start("output/mysqldump-php_test014b.sql"); exit(0); diff --git a/tests/scripts/test.sh b/tests/scripts/test.sh index aef10243..c5c18a95 100755 --- a/tests/scripts/test.sh +++ b/tests/scripts/test.sh @@ -1,9 +1,10 @@ #!/bin/bash HOST=${1:-db} -USER=travis -MYSQL_CMD="mysql -h $HOST -u $USER" -MYSQLDUMP_CMD="mysqldump -h $HOST -u $USER" +USER=example +PASS=example +MYSQL_CMD="mysql -h $HOST -u $USER -p$PASS" +MYSQLDUMP_CMD="mysqldump -h $HOST -u $USER -p$PASS" major=`$MYSQL_CMD -e "SELECT @@version\G" | grep version |awk '{print $2}' | awk -F"." '{print $1}'` medium=`$MYSQL_CMD -e "SELECT @@version\G" | grep version |awk '{print $2}' | awk -F"." '{print $2}'` diff --git a/tests/scripts/test001.src.sql b/tests/scripts/test001.src.sql index 43622e0b..4515a745 100644 --- a/tests/scripts/test001.src.sql +++ b/tests/scripts/test001.src.sql @@ -113,10 +113,10 @@ INSERT INTO `test033` VALUES (1,'test test test'); DROP VIEW IF EXISTS `test100`; -CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `test100` AS select `test000`.`id` AS `id`,`test000`.`col01` AS `col01`,`test000`.`col02` AS `col02`,`test000`.`col03` AS `col03`,`test000`.`col10` AS `col10`,`test000`.`col11` AS `col11`,`test000`.`col15` AS `col15`,`test000`.`col27` AS `col27` from `test000`; +CREATE ALGORITHM=UNDEFINED DEFINER=`example`@`localhost` SQL SECURITY DEFINER VIEW `test100` AS select `test000`.`id` AS `id`,`test000`.`col01` AS `col01`,`test000`.`col02` AS `col02`,`test000`.`col03` AS `col03`,`test000`.`col10` AS `col10`,`test000`.`col11` AS `col11`,`test000`.`col15` AS `col15`,`test000`.`col27` AS `col27` from `test000`; DROP VIEW IF EXISTS `test127`; -CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `test127` AS select `test027`.`id` AS `id`,`test027`.`col` AS `col` from `test027`; +CREATE ALGORITHM=UNDEFINED DEFINER=`example`@`localhost` SQL SECURITY DEFINER VIEW `test127` AS select `test027`.`id` AS `id`,`test027`.`col` AS `col` from `test027`; DROP TABLE IF EXISTS `test200`; diff --git a/tests/scripts/test006.src.sql b/tests/scripts/test006.src.sql index 66114667..f7af5800 100644 --- a/tests/scripts/test006.src.sql +++ b/tests/scripts/test006.src.sql @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS `view_of_my_table` ( -- DROP TABLE IF EXISTS `my_view`; -CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `my_view` AS select `view_of_my_table`.`id` AS `id`,`view_of_my_table`.`name` AS `name`,`view_of_my_table`.`lastname` AS `lastname`,`view_of_my_table`.`username` AS `username` from `view_of_my_table`; +CREATE ALGORITHM=UNDEFINED DEFINER=`example`@`localhost` SQL SECURITY DEFINER VIEW `my_view` AS select `view_of_my_table`.`id` AS `id`,`view_of_my_table`.`name` AS `name`,`view_of_my_table`.`lastname` AS `lastname`,`view_of_my_table`.`username` AS `username` from `view_of_my_table`; -- -------------------------------------------------------- @@ -81,7 +81,7 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIE -- DROP TABLE IF EXISTS `view_of_my_table`; -CREATE ALGORITHM=UNDEFINED DEFINER=`travis`@`localhost` SQL SECURITY DEFINER VIEW `view_of_my_table` AS select `my_table`.`id` AS `id`,`my_table`.`name` AS `name`,`my_table`.`lastname` AS `lastname`,`my_table`.`username` AS `username` from `my_table`; +CREATE ALGORITHM=UNDEFINED DEFINER=`example`@`localhost` SQL SECURITY DEFINER VIEW `view_of_my_table` AS select `my_table`.`id` AS `id`,`my_table`.`name` AS `name`,`my_table`.`lastname` AS `lastname`,`my_table`.`username` AS `username` from `my_table`; -- -- Índices para tablas volcadas diff --git a/tests/scripts/test010.8.src.sql b/tests/scripts/test010.8.src.sql index 265a032f..4f8e22fd 100644 --- a/tests/scripts/test010.8.src.sql +++ b/tests/scripts/test010.8.src.sql @@ -35,7 +35,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`travis`@`%`*/ /*!50106 EVENT `e_test010` ON SCHEDULE AT '2030-01-01 23:59:00' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO test010.test VALUES (NOW()) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`example`@`%`*/ /*!50106 EVENT `e_test010` ON SCHEDULE AT '2030-01-01 23:59:00' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO test010.test VALUES (NOW()) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; diff --git a/tests/scripts/test010.src.sql b/tests/scripts/test010.src.sql index 21022843..169e9dfa 100644 --- a/tests/scripts/test010.src.sql +++ b/tests/scripts/test010.src.sql @@ -35,7 +35,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`travis`@`%`*/ /*!50106 EVENT `e_test010` ON SCHEDULE AT '2030-01-01 23:59:00' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO test010.test VALUES (NOW()) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`example`@`%`*/ /*!50106 EVENT `e_test010` ON SCHEDULE AT '2030-01-01 23:59:00' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO test010.test VALUES (NOW()) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; From e6747c779101e71104e13a81ba94950660cbc708 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 12:32:54 +0200 Subject: [PATCH 02/22] GHA: try importing init sql --- .github/workflows/tests.yml | 4 ++-- compose.yaml | 2 +- .../{mysql-8.0-init.sql => mysql-init.sql} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename docker-entrypoint-initdb.d/{mysql-8.0-init.sql => mysql-init.sql} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3eccba95..4aae1651 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -84,7 +84,7 @@ jobs: run: vendor/bin/phpunit - name: Create user and databases for testing - run: cd tests/scripts && ./create_users.sh 127.0.0.1 + run: mysql -u example -pexample example < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql - name: Run test script - run: cd tests/scripts && ./test.sh 127.0.0.1 + run: tests/scripts/test.sh 127.0.0.1 diff --git a/compose.yaml b/compose.yaml index 3d074b3b..8d413690 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,7 +6,7 @@ services: env_file: - .env.mysql volumes: - - ./docker-entrypoint-initdb.d/mysql-8.0-init.sql:/docker-entrypoint-initdb.d/00-init.sql + - ./docker-entrypoint-initdb.d/mysql-init.sql:/docker-entrypoint-initdb.d/00-init.sql db2: container_name: mysqldump-php-mariadb-10 diff --git a/docker-entrypoint-initdb.d/mysql-8.0-init.sql b/docker-entrypoint-initdb.d/mysql-init.sql similarity index 100% rename from docker-entrypoint-initdb.d/mysql-8.0-init.sql rename to docker-entrypoint-initdb.d/mysql-init.sql From 4f18876698fcff128189372fabc4523df82640b8 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 12:34:31 +0200 Subject: [PATCH 03/22] GHA: try importing init sql 2 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4aae1651..36efe785 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -84,7 +84,7 @@ jobs: run: vendor/bin/phpunit - name: Create user and databases for testing - run: mysql -u example -pexample example < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql + run: mysql -u root -pexample < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql - name: Run test script run: tests/scripts/test.sh 127.0.0.1 From a603be368d25885b70cb18e80009f16659b9c8a8 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 12:36:18 +0200 Subject: [PATCH 04/22] GHA: try importing init sql 3 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 36efe785..f779a0ed 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -87,4 +87,4 @@ jobs: run: mysql -u root -pexample < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql - name: Run test script - run: tests/scripts/test.sh 127.0.0.1 + run: cd tests/scripts && ./test.sh 127.0.0.1 From 41b986e78341960f2e21dac84dc96135ea50ad3e Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 14:37:46 +0200 Subject: [PATCH 05/22] Fix double space in INSERT IGNORE --- README.md | 16 ++++++++-------- compose.yaml | 20 ++++++++++---------- src/Mysqldump.php | 2 +- tests/scripts/test.php | 2 +- tests/scripts/test.sh | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5c6d4a85..38af158f 100644 --- a/README.md +++ b/README.md @@ -239,14 +239,14 @@ Local setup for tests: ```console docker compose up --wait --build -docker compose exec -w /app/tests/scripts php81 ./test.sh db1 -docker compose exec -w /app/tests/scripts php82 ./test.sh db1 -docker compose exec -w /app/tests/scripts php83 ./test.sh db1 -docker compose exec -w /app/tests/scripts php84 ./test.sh db1 -docker compose exec -w /app/tests/scripts php81 ./test.sh db2 -docker compose exec -w /app/tests/scripts php82 ./test.sh db2 -docker compose exec -w /app/tests/scripts php83 ./test.sh db2 -docker compose exec -w /app/tests/scripts php84 ./test.sh db2 +docker compose exec -w /app/tests/scripts php81 ./test.sh mysql +docker compose exec -w /app/tests/scripts php82 ./test.sh mysql +docker compose exec -w /app/tests/scripts php83 ./test.sh mysql +docker compose exec -w /app/tests/scripts php84 ./test.sh mysql +docker compose exec -w /app/tests/scripts php81 ./test.sh mariadb +docker compose exec -w /app/tests/scripts php82 ./test.sh mariadb +docker compose exec -w /app/tests/scripts php83 ./test.sh mariadb +docker compose exec -w /app/tests/scripts php84 ./test.sh mariadb ``` ## Credits diff --git a/compose.yaml b/compose.yaml index 8d413690..b2d76ba3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,6 @@ services: - db1: + mysql: container_name: mysqldump-php-mysql-80 image: mysql:8.0 env_file: @@ -8,7 +8,7 @@ services: volumes: - ./docker-entrypoint-initdb.d/mysql-init.sql:/docker-entrypoint-initdb.d/00-init.sql - db2: + mariadb: container_name: mysqldump-php-mariadb-10 image: mariadb:10.11 env_file: @@ -25,8 +25,8 @@ services: volumes: - .:/app depends_on: - - db1 - - db2 + - mysql + - mariadb php82: container_name: mysqldump-php-82 @@ -37,8 +37,8 @@ services: volumes: - .:/app depends_on: - - db1 - - db2 + - mysql + - mariadb php83: container_name: mysqldump-php-83 @@ -49,8 +49,8 @@ services: volumes: - .:/app depends_on: - - db1 - - db2 + - mysql + - mariadb php84: container_name: mysqldump-php-84 @@ -61,5 +61,5 @@ services: volumes: - .:/app depends_on: - - db1 - - db2 + - mysql + - mariadb diff --git a/src/Mysqldump.php b/src/Mysqldump.php index 2216fa91..e4a66c62 100644 --- a/src/Mysqldump.php +++ b/src/Mysqldump.php @@ -836,7 +836,7 @@ private function listValues(string $tableName) $resultSet = $this->conn->query($stmt); $resultSet->setFetchMode(PDO::FETCH_ASSOC); - $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; + $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; $count = 0; $isInfoCallable = $this->infoCallable && is_callable($this->infoCallable); diff --git a/tests/scripts/test.php b/tests/scripts/test.php index de0896d4..39a15bc2 100644 --- a/tests/scripts/test.php +++ b/tests/scripts/test.php @@ -9,7 +9,7 @@ use Druidfi\Mysqldump\Mysqldump; use Druidfi\Mysqldump\Compress\CompressManagerFactory; -$host = $argv[1] ?? 'db'; // Get host name from test.sh +$host = $argv[1] ?? 'mysql'; // Get host name from test.sh $user = 'example'; $pass = 'example'; diff --git a/tests/scripts/test.sh b/tests/scripts/test.sh index c5c18a95..2187c56e 100755 --- a/tests/scripts/test.sh +++ b/tests/scripts/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -HOST=${1:-db} +HOST=${1:-mysql} USER=example PASS=example MYSQL_CMD="mysql -h $HOST -u $USER -p$PASS" From e7747f97bf2a0486af5049618e311bd500a81ea3 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 14:48:46 +0200 Subject: [PATCH 06/22] GHA: use docker images as databases --- .github/workflows/tests.yml | 68 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f779a0ed..fd37076d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,55 +14,59 @@ jobs: runs-on: ${{ matrix.os }} + services: + db: + image: ${{ matrix.database_image }} + env: + # The MySQL docker container requires these environment variables to be set + # so we can create and migrate the test database. + # See: https://hub.docker.com/_/mysql + MYSQL_ROOT_PASSWORD: mysql + MYSQL_DATABASE: mysql + MYSQL_USER: mysql + MYSQL_PASSWORD: mysql + ports: + # Opens port 3306 on service container and host + # https://docs.github.com/en/actions/using-containerized-services/about-service-containers + - 3306:3306 + # Before continuing, verify the mysql container is reachable from the ubuntu host + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: fail-fast: false matrix: include: + # MySQL 8.0 - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '8.1' + database_image: mysql:8.0 + php-version: 8.1 - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '8.2' + database_image: mysql:8.0 + php-version: 8.2 - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '8.3' + database_image: mysql:8.0 + php-version: 8.3 - os: ubuntu-latest - database: 'mysql' - database-version: '8.0' - php-version: '8.4' + database_image: mysql:8.0 + php-version: 8.4 + # MariaDB 10.11 LTS - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '8.1' + database_image: mariadb:10.11 + php-version: 8.1 - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '8.2' + database_image: mariadb:10.11 + php-version: 8.2 - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '8.3' + database_image: mariadb:10.11 + php-version: 8.3 - os: ubuntu-20.04 - database: 'mariadb' - database-version: '10.11' - php-version: '8.4' + database_image: mariadb:10.11 + php-version: 8.4 steps: - - uses: shogo82148/actions-setup-mysql@v1 - with: - distribution: '${{ matrix.database }}' - mysql-version: '${{ matrix.database-version }}' - user: 'example' - password: 'example' - root-password: 'example' - - name: Checkout code uses: actions/checkout@v4 with: From a85002501c7f162a50c60f416aefde1696a29099 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 14:52:30 +0200 Subject: [PATCH 07/22] GHA: use docker images as databases 2 --- .github/workflows/tests.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd37076d..1a23e006 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: services: db: - image: ${{ matrix.database_image }} + image: ${{ matrix.database }}:${{ matrix.database_version }} env: # The MySQL docker container requires these environment variables to be set # so we can create and migrate the test database. @@ -39,30 +39,38 @@ jobs: # MySQL 8.0 - os: ubuntu-latest - database_image: mysql:8.0 + database: mysql + database_version: 8.0 php-version: 8.1 - os: ubuntu-latest - database_image: mysql:8.0 + database: mysql + database_version: 8.0 php-version: 8.2 - os: ubuntu-latest - database_image: mysql:8.0 + database: mysql + database_version: 8.0 php-version: 8.3 - os: ubuntu-latest - database_image: mysql:8.0 + database: mysql + database_version: 8.0 php-version: 8.4 # MariaDB 10.11 LTS - os: ubuntu-20.04 - database_image: mariadb:10.11 + database: mariadb + database_version: 10.11 php-version: 8.1 - os: ubuntu-20.04 - database_image: mariadb:10.11 + database: mariadb + database_version: 10.11 php-version: 8.2 - os: ubuntu-20.04 - database_image: mariadb:10.11 + database: mariadb + database_version: 10.11 php-version: 8.3 - os: ubuntu-20.04 - database_image: mariadb:10.11 + database: mariadb + database_version: 10.11 php-version: 8.4 steps: From 38601400f2c6da2d26c4d9fb2f1d9dfe7175b95b Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 14:54:05 +0200 Subject: [PATCH 08/22] GHA: use docker images as databases 3 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a23e006..64cdd352 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,7 +96,7 @@ jobs: run: vendor/bin/phpunit - name: Create user and databases for testing - run: mysql -u root -pexample < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql + run: mysql -h 127.0.0.1 -u root -pexample < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql - name: Run test script run: cd tests/scripts && ./test.sh 127.0.0.1 From 5b3d5ba9768fdf0c7ab60a6a586386cfc54048a2 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 14:55:52 +0200 Subject: [PATCH 09/22] GHA: use docker images as databases 4 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 64cdd352..8c1be138 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,7 +96,7 @@ jobs: run: vendor/bin/phpunit - name: Create user and databases for testing - run: mysql -h 127.0.0.1 -u root -pexample < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql + run: mysql -h 127.0.0.1 -u root -pmysql < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql - name: Run test script run: cd tests/scripts && ./test.sh 127.0.0.1 From e4de88b6e82a67a09dfff6b650886b291235105f Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 15:15:47 +0200 Subject: [PATCH 10/22] GHA: use docker images as databases 5 --- .github/workflows/tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c1be138..fb8caa88 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,10 +21,10 @@ jobs: # The MySQL docker container requires these environment variables to be set # so we can create and migrate the test database. # See: https://hub.docker.com/_/mysql - MYSQL_ROOT_PASSWORD: mysql - MYSQL_DATABASE: mysql - MYSQL_USER: mysql - MYSQL_PASSWORD: mysql + MYSQL_ROOT_PASSWORD: example + MYSQL_DATABASE: example + MYSQL_USER: example + MYSQL_PASSWORD: example ports: # Opens port 3306 on service container and host # https://docs.github.com/en/actions/using-containerized-services/about-service-containers @@ -96,7 +96,7 @@ jobs: run: vendor/bin/phpunit - name: Create user and databases for testing - run: mysql -h 127.0.0.1 -u root -pmysql < docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql + run: cat docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql | mysql -h127.0.0.1 -uroot -pexample - name: Run test script run: cd tests/scripts && ./test.sh 127.0.0.1 From 8f013d719442efaa55e782280e1422058fd89f09 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 15:34:46 +0200 Subject: [PATCH 11/22] GHA: use docker images as databases 6 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb8caa88..d9ce9dcf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: # https://docs.github.com/en/actions/using-containerized-services/about-service-containers - 3306:3306 # Before continuing, verify the mysql container is reachable from the ubuntu host - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --default-authentication-plugin=mysql_native_password --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: fail-fast: false From 0bf521c893c53d1d8d0038611065511416332886 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 15:36:27 +0200 Subject: [PATCH 12/22] GHA: use docker images as databases 7 --- .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 d9ce9dcf..36698fd0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,12 +25,13 @@ jobs: MYSQL_DATABASE: example MYSQL_USER: example MYSQL_PASSWORD: example + MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password ports: # Opens port 3306 on service container and host # https://docs.github.com/en/actions/using-containerized-services/about-service-containers - 3306:3306 # Before continuing, verify the mysql container is reachable from the ubuntu host - options: --default-authentication-plugin=mysql_native_password --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: fail-fast: false From 8b8647b45752847741acaa624a136dd94d2741f1 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 15:44:26 +0200 Subject: [PATCH 13/22] GHA: use docker images as databases 8 bitnami images --- .github/workflows/tests.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 36698fd0..29b65d91 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: services: db: - image: ${{ matrix.database }}:${{ matrix.database_version }} + image: ${{ matrix.database_image }} env: # The MySQL docker container requires these environment variables to be set # so we can create and migrate the test database. @@ -41,37 +41,37 @@ jobs: # MySQL 8.0 - os: ubuntu-latest database: mysql - database_version: 8.0 + database_image: bitnami/mysql:8.0 php-version: 8.1 - os: ubuntu-latest database: mysql - database_version: 8.0 + database_image: bitnami/mysql:8.0 php-version: 8.2 - os: ubuntu-latest database: mysql - database_version: 8.0 + database_image: bitnami/mysql:8.0 php-version: 8.3 - os: ubuntu-latest database: mysql - database_version: 8.0 + database_image: bitnami/mysql:8.0 php-version: 8.4 # MariaDB 10.11 LTS - os: ubuntu-20.04 database: mariadb - database_version: 10.11 + database_image: bitnami/mariadb:10.11 php-version: 8.1 - os: ubuntu-20.04 database: mariadb - database_version: 10.11 + database_image: bitnami/mariadb:10.11 php-version: 8.2 - os: ubuntu-20.04 database: mariadb - database_version: 10.11 + database_image: bitnami/mariadb:10.11 php-version: 8.3 - os: ubuntu-20.04 database: mariadb - database_version: 10.11 + database_image: bitnami/mariadb:10.11 php-version: 8.4 steps: From aa78d75b54b8358556575a1256ff05f717cff50d Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 17:34:31 +0200 Subject: [PATCH 14/22] GHA: use docker images as databases 9 bitnami images --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29b65d91..d31dc851 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,7 @@ jobs: # The MySQL docker container requires these environment variables to be set # so we can create and migrate the test database. # See: https://hub.docker.com/_/mysql + MARIADB_ROOT_PASSWORD: example MYSQL_ROOT_PASSWORD: example MYSQL_DATABASE: example MYSQL_USER: example From 118207bf6cda86793a5b2ee0edd1c50496a54e64 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 17:37:55 +0200 Subject: [PATCH 15/22] GHA: use docker images as databases 10 bitnami images --- .env.mysql | 1 + compose.yaml | 4 ++-- src/Mysqldump.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.env.mysql b/.env.mysql index 27eb068f..fb32c0cd 100644 --- a/.env.mysql +++ b/.env.mysql @@ -1,3 +1,4 @@ +MARIADB_ROOT_PASSWORD=mysql MYSQL_ROOT_PASSWORD=mysql MYSQL_DATABASE=mysql MYSQL_USER=mysql diff --git a/compose.yaml b/compose.yaml index b2d76ba3..3d0b50b8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,7 +2,7 @@ services: mysql: container_name: mysqldump-php-mysql-80 - image: mysql:8.0 + image: bitnami/mysql:8.0 env_file: - .env.mysql volumes: @@ -10,7 +10,7 @@ services: mariadb: container_name: mysqldump-php-mariadb-10 - image: mariadb:10.11 + image: bitnami/mariadb:10.11 env_file: - .env.mysql volumes: diff --git a/src/Mysqldump.php b/src/Mysqldump.php index e4a66c62..2216fa91 100644 --- a/src/Mysqldump.php +++ b/src/Mysqldump.php @@ -836,7 +836,7 @@ private function listValues(string $tableName) $resultSet = $this->conn->query($stmt); $resultSet->setFetchMode(PDO::FETCH_ASSOC); - $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; + $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; $count = 0; $isInfoCallable = $this->infoCallable && is_callable($this->infoCallable); From 1a9a2c6a3b42c998a66035ea09340f6eef1f0b4e Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 17:57:33 +0200 Subject: [PATCH 16/22] GHA: use docker images as databases 11 --- .github/workflows/tests.yml | 3 ++ src/Mysqldump.php | 2 +- tests/scripts/test.sh | 67 ----------------------------------- tests/scripts/test011.src.sql | 53 --------------------------- 4 files changed, 4 insertions(+), 121 deletions(-) delete mode 100644 tests/scripts/test011.src.sql diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d31dc851..3f314fe5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,6 +97,9 @@ jobs: - name: Run PHPunit tests run: vendor/bin/phpunit + - name: Get mysqldump version + run: mysqldump --version + - name: Create user and databases for testing run: cat docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql | mysql -h127.0.0.1 -uroot -pexample diff --git a/src/Mysqldump.php b/src/Mysqldump.php index 2216fa91..e4a66c62 100644 --- a/src/Mysqldump.php +++ b/src/Mysqldump.php @@ -836,7 +836,7 @@ private function listValues(string $tableName) $resultSet = $this->conn->query($stmt); $resultSet->setFetchMode(PDO::FETCH_ASSOC); - $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; + $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; $count = 0; $isInfoCallable = $this->infoCallable && is_callable($this->infoCallable); diff --git a/tests/scripts/test.sh b/tests/scripts/test.sh index 2187c56e..fde194c6 100755 --- a/tests/scripts/test.sh +++ b/tests/scripts/test.sh @@ -72,18 +72,9 @@ else if [[ $errCode -ne 0 ]]; then echo "error test010.8.src.sql"; fi fi -if [[ $major -eq 5 && $medium -ge 7 ]]; then - printf "Import test011.src.sql" - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - $MYSQL_CMD < test011.src.sql && echo " - done."; errCode=$?; ret[((index++))]=$errCode -else - echo "test011 disabled, only valid for mysql server version 5.7.x" -fi - printf "Import test012.src.sql" $MYSQL_CMD < test012.src.sql && echo " - done."; errCode=$?; ret[((index++))]=$errCode if [[ $errCode -ne 0 ]]; then echo "error test012.src.sql"; fi -#$MYSQL_CMD < test013.src.sql; errCode=$?; ret[((index++))]=$errCode printf "Import test014.src.sql" $MYSQL_CMD < test014.src.sql && echo " - done."; errCode=$?; ret[((index++))]=$errCode @@ -199,21 +190,6 @@ cat test002.src.sql | grep ^INSERT > output/test002.filtered.sql && echo "Create cat test005.src.sql | grep ^INSERT > output/test005.filtered.sql && echo "Created test005.filtered.sql" cat test008.src.sql | grep FOREIGN > output/test008.filtered.sql && echo "Created test008.filtered.sql" cat test010.src.sql | grep CREATE | grep EVENT > output/test010.filtered.sql && echo "Created test010.filtered.sql" - -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - cat test011.src.sql | egrep "INSERT|GENERATED" > output/test011.filtered.sql && echo "Created test011.filtered.sql" -else - echo "test011 disabled, only valid for mysql server version 5.7.x" -fi - -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - cat test014.src.sql | egrep "INSERT|GENERATED" > output/test014.filtered.sql && echo "Created test014.filtered.sql" -else - echo "test014 disabled, only valid for mysql server version 5.7.x" -fi - cat output/mysqldump_test001.sql | grep ^INSERT > output/mysqldump_test001.filtered.sql && echo "Created mysqldump_test001.filtered.sql" cat output/mysqldump_test001_complete.sql | grep ^INSERT > output/mysqldump_test001_complete.filtered.sql && echo "Created mysqldump_test001_complete.filtered.sql" cat output/mysqldump_test002.sql | grep ^INSERT > output/mysqldump_test002.filtered.sql && echo "Created mysqldump_test002.filtered.sql" @@ -227,25 +203,9 @@ cat output/mysqldump-php_test005.sql | grep ^INSERT > output/mysqldump-php_test0 cat output/mysqldump-php_test008.sql | grep FOREIGN > output/mysqldump-php_test008.filtered.sql && echo "Created mysqldump-php_test008.filtered.sql" cat output/mysqldump-php_test010.sql | grep CREATE | grep EVENT > output/mysqldump-php_test010.filtered.sql && echo "Created mysqldump-php_test010.filtered.sql" -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - cat output/mysqldump-php_test011a.sql | egrep "INSERT|GENERATED" > output/mysqldump-php_test011a.filtered.sql && echo "Created mysqldump-php_test011a.filtered.sql" - cat output/mysqldump-php_test011b.sql | egrep "INSERT|GENERATED" > output/mysqldump-php_test011b.filtered.sql && echo "Created mysqldump-php_test011b.filtered.sql" -else - echo "test011 disabled, only valid for mysql server version 5.7.x" -fi - cat output/mysqldump-php_test012.sql | grep -E -e '50001 (CREATE|VIEW)' -e '50013 DEFINER' -e 'CREATE.*TRIGGER' -e 'FUNCTION' -e 'PROCEDURE' > output/mysqldump-php_test012.filtered.sql && echo "Created mysqldump-php_test012.filtered.sql" cat output/mysqldump-php_test013.sql | grep INSERT > output/mysqldump-php_test013.filtered.sql && echo "Created mysqldump-php_test013.filtered.sql" -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - cat output/mysqldump-php_test014a.sql | egrep "INSERT|GENERATED" > output/mysqldump-php_test014a.filtered.sql && echo "Created mysqldump-php_test014a.filtered.sql" - cat output/mysqldump-php_test014b.sql | egrep "INSERT|GENERATED" > output/mysqldump-php_test014b.filtered.sql && echo "Created mysqldump-php_test014b.filtered.sql" -else - echo "test014 disabled, only valid for mysql server version 5.7.x" -fi - printf "\nRun diff tests:\n\n" test="Test#$index diff test001.filtered.sql mysqldump_test001.filtered.sql" @@ -313,20 +273,6 @@ diff output/test010.filtered.sql output/mysqldump-php_test010.filtered.sql errCode=$?; ret[((index++))]=$errCode if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - test="Test#$index diff test011.filtered.sql mysqldump-php_test011a.filtered.sql" - diff output/test011.filtered.sql output/mysqldump-php_test011a.filtered.sql - errCode=$?; ret[((index++))]=$errCode - if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi - test="Test#$index diff test011.filtered.sql mysqldump-php_test011b.filtered.sql" - diff output/test011.filtered.sql output/mysqldump-php_test011b.filtered.sql - errCode=$?; ret[((index++))]=$errCode - if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi -else - echo "test011 disabled, only valid for mysql server version 5.7.x" -fi - # Test create views, events, trigger test="Test#$index diff mysqldump_test012.filtered.sql mysqldump-php_test012.filtered.sql" diff output/mysqldump_test012.filtered.sql output/mysqldump-php_test012.filtered.sql @@ -345,19 +291,6 @@ diff output/mysqldump_test013.filtered.sql output/mysqldump-php_test013.filtered errCode=$?; ret[((index++))]=$errCode if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi -if [[ $major -eq 5 && $medium -ge 7 ]]; then - # test virtual column support, with simple inserts forced to complete (a) and complete inserts (b) - test="Test#$index diff test014.filtered.sql mysqldump-php_test014a.filtered.sql" - diff output/test014.filtered.sql output/mysqldump-php_test014a.filtered.sql - errCode=$?; ret[((index++))]=$errCode - if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi - test="Test#$index diff test014.filtered.sql mysqldump-php_test014b.filtered.sql" - diff output/test014.filtered.sql output/mysqldump-php_test014b.filtered.sql - errCode=$?; ret[((index++))]=$errCode - if [[ $errCode -ne 0 ]]; then echo -e "\n$test\n"; fi -else - echo "test011 disabled, only valid for mysql server version 5.7.x" -fi echo -e "\nDone $index tests\n" retvalue=0 diff --git a/tests/scripts/test011.src.sql b/tests/scripts/test011.src.sql deleted file mode 100644 index 1be17416..00000000 --- a/tests/scripts/test011.src.sql +++ /dev/null @@ -1,53 +0,0 @@ -DROP DATABASE IF EXISTS `test011`; -CREATE DATABASE `test011`; -USE `test011`; - --- MySQL dump 10.13 Distrib 5.7.15, for Linux (x86_64) --- --- Host: localhost Database: test --- ------------------------------------------------------ --- Server version 5.7.15 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `test011` --- - -DROP TABLE IF EXISTS `test011`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `test011` ( - `id` int(11) NOT NULL, - `hash_stored` char(32) CHARACTER SET ascii COLLATE ascii_bin GENERATED ALWAYS AS (md5(`id`)) STORED NOT NULL, - `hash_virtual` char(32) CHARACTER SET ascii COLLATE ascii_bin GENERATED ALWAYS AS (md5(`id`)) VIRTUAL NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `test011` --- - -LOCK TABLES `test011` WRITE; -/*!40000 ALTER TABLE `test011` DISABLE KEYS */; -INSERT INTO `test011` (`id`) VALUES (159413),(294775); -/*!40000 ALTER TABLE `test011` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; From 5f236a3d2999190362514e09022eb6266f4e4b3e Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 18:55:54 +0200 Subject: [PATCH 17/22] GHA: use docker images as databases 12 --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f314fe5..7752e850 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,6 +77,9 @@ jobs: steps: + - name: Validate composer.json + run: docker ps && exit 0 + - name: Checkout code uses: actions/checkout@v4 with: From 0b0337dbabfcacb7ecf14b5196fb2362be5fc997 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 18:58:22 +0200 Subject: [PATCH 18/22] GHA: use docker images as databases 13 --- .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 7752e850..9b638c45 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: # https://docs.github.com/en/actions/using-containerized-services/about-service-containers - 3306:3306 # Before continuing, verify the mysql container is reachable from the ubuntu host - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --name db --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: fail-fast: false @@ -78,7 +78,7 @@ jobs: steps: - name: Validate composer.json - run: docker ps && exit 0 + run: docker exec db mysqldump --version && exit 0 - name: Checkout code uses: actions/checkout@v4 From efcb2dc9511b40df47ec86cab0770366b14f14bc Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 19:01:05 +0200 Subject: [PATCH 19/22] GHA: use docker images as databases 14 --- .github/workflows/tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b638c45..cc0b7003 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,8 +77,11 @@ jobs: steps: - - name: Validate composer.json - run: docker exec db mysqldump --version && exit 0 + - name: Setup mysqldump + run: | + shopt -s expand_aliases + mysqldump='docker exec db mysqldump' + mysqldump --version - name: Checkout code uses: actions/checkout@v4 From 41733df93f7250b511dc1fc5e9f67df779381f01 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 19:03:17 +0200 Subject: [PATCH 20/22] GHA: use docker images as databases 15 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cc0b7003..d5e21541 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,7 +80,7 @@ jobs: - name: Setup mysqldump run: | shopt -s expand_aliases - mysqldump='docker exec db mysqldump' + alias mysqldump='docker exec db mysqldump' mysqldump --version - name: Checkout code From 462b694a75622ceb34fa04bf978521be55e15315 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 19:04:56 +0200 Subject: [PATCH 21/22] GHA: use docker images as databases 16 --- .github/workflows/tests.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5e21541..c4db4159 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,12 +77,6 @@ jobs: steps: - - name: Setup mysqldump - run: | - shopt -s expand_aliases - alias mysqldump='docker exec db mysqldump' - mysqldump --version - - name: Checkout code uses: actions/checkout@v4 with: @@ -103,11 +97,12 @@ jobs: - name: Run PHPunit tests run: vendor/bin/phpunit - - name: Get mysqldump version - run: mysqldump --version - - name: Create user and databases for testing run: cat docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql | mysql -h127.0.0.1 -uroot -pexample - name: Run test script - run: cd tests/scripts && ./test.sh 127.0.0.1 + run: | + shopt -s expand_aliases + alias mysqldump='docker exec db mysqldump' + mysqldump --version + cd tests/scripts && ./test.sh 127.0.0.1 From 089db947844973157f5dbcf89c4d176fe869124b Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 27 Nov 2024 19:07:59 +0200 Subject: [PATCH 22/22] GHA: use docker images as databases 17 --- src/Mysqldump.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mysqldump.php b/src/Mysqldump.php index e4a66c62..2216fa91 100644 --- a/src/Mysqldump.php +++ b/src/Mysqldump.php @@ -836,7 +836,7 @@ private function listValues(string $tableName) $resultSet = $this->conn->query($stmt); $resultSet->setFetchMode(PDO::FETCH_ASSOC); - $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; + $ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : ''; $count = 0; $isInfoCallable = $this->infoCallable && is_callable($this->infoCallable);