From d18bb5ff08db0ef69c70dd3ebd6666889ee8f220 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 10 Nov 2023 15:06:33 +0100 Subject: [PATCH 01/34] Add support for MySQL socket connection --- src/Config_Command.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Config_Command.php b/src/Config_Command.php index b9961457..854d5aab 100644 --- a/src/Config_Command.php +++ b/src/Config_Command.php @@ -163,7 +163,13 @@ public function create( $_, $assoc_args ) { $mysql = mysqli_init(); mysqli_report( MYSQLI_REPORT_STRICT ); try { - mysqli_real_connect( $mysql, $assoc_args['dbhost'], $assoc_args['dbuser'], $assoc_args['dbpass'] ); + if ( file_exists($assoc_args['dbhost']) ) { + // If dbhost is a path to a socket + mysqli_real_connect( $mysql, null, $assoc_args['dbuser'], $assoc_args['dbpass'], null, null, $assoc_args['dbhost'] ); + } else { + // If dbhost is a hostname or IP address + mysqli_real_connect( $mysql, $assoc_args['dbhost'], $assoc_args['dbuser'], $assoc_args['dbpass'] ); + } } catch ( mysqli_sql_exception $exception ) { WP_CLI::error( 'Database connection error (' . $exception->getCode() . ') ' . $exception->getMessage() ); } From 31157da468c47a3b685a2e034a29dc0c3fca1275 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 10 Nov 2023 15:16:26 +0100 Subject: [PATCH 02/34] Fix formatting --- src/Config_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config_Command.php b/src/Config_Command.php index 854d5aab..a1b00831 100644 --- a/src/Config_Command.php +++ b/src/Config_Command.php @@ -163,7 +163,7 @@ public function create( $_, $assoc_args ) { $mysql = mysqli_init(); mysqli_report( MYSQLI_REPORT_STRICT ); try { - if ( file_exists($assoc_args['dbhost']) ) { + if ( file_exists( $assoc_args['dbhost'] ) ) { // If dbhost is a path to a socket mysqli_real_connect( $mysql, null, $assoc_args['dbuser'], $assoc_args['dbpass'], null, null, $assoc_args['dbhost'] ); } else { From 7b792ed284b2971d8e65c3ada8ac5c7fa98e7b31 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 10 Nov 2023 15:46:55 +0100 Subject: [PATCH 03/34] Add test for the socket connection --- features/config-create.feature | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/features/config-create.feature b/features/config-create.feature index 15b4ca9f..2a0a1243 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -160,6 +160,17 @@ Feature: Create a wp-config file Error: Database connection error """ + @require-mysql + Scenario: Configure with database credentials using socket path + Given an empty directory + And WP files + + When I try `wp config create {CORE_CONFIG_SETTINGS} --dbhost=/tmp/mysql.sock` + Then the wp-config.php file should contain: + """ + define( 'DB_HOST', '/tmp/mysql.sock' ); + """ + @require-php-7.0 Scenario: Configure with salts generated Given an empty directory From ff8be3351f10926d9467cec1786e6c5a2b4cb15d Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 10 Nov 2023 15:53:32 +0100 Subject: [PATCH 04/34] Skip using real database and check if DB_HOST is written --- features/config-create.feature | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 2a0a1243..c0bf0031 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -160,12 +160,11 @@ Feature: Create a wp-config file Error: Database connection error """ - @require-mysql Scenario: Configure with database credentials using socket path Given an empty directory And WP files - When I try `wp config create {CORE_CONFIG_SETTINGS} --dbhost=/tmp/mysql.sock` + When I try `wp config create {CORE_CONFIG_SETTINGS} --dbhost=/tmp/mysql.sock --skip-check` Then the wp-config.php file should contain: """ define( 'DB_HOST', '/tmp/mysql.sock' ); From 976b7c6754c9f2b6c9bc74ae09555d4fb3945695 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 10 Nov 2023 09:50:57 -0800 Subject: [PATCH 05/34] Get the socket from MySQL from the valid connection --- features/config-create.feature | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index c0bf0031..b166a19b 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -160,14 +160,20 @@ Feature: Create a wp-config file Error: Database connection error """ + @require-mysql Scenario: Configure with database credentials using socket path - Given an empty directory - And WP files + Given a WP install + + When I run `wp db query 'SELECT @@GLOBAL.SOCKET' --skip-column-names` + Then save STDOUT as {SOCKET} + + When I run `rm wp-config.php` + Then the wp-config.php file should not exist - When I try `wp config create {CORE_CONFIG_SETTINGS} --dbhost=/tmp/mysql.sock --skip-check` + When I run `wp config create {CORE_CONFIG_SETTINGS} --dbhost={SOCKET}` Then the wp-config.php file should contain: """ - define( 'DB_HOST', '/tmp/mysql.sock' ); + define( 'DB_HOST', '{SOCKET}' ); """ @require-php-7.0 From 94680566c25847c8019d0fecad7672331d7de99d Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 10 Nov 2023 11:16:39 -0800 Subject: [PATCH 06/34] Use a file-based socket finder --- features/config-create.feature | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index b166a19b..96be4708 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -162,14 +162,24 @@ Feature: Create a wp-config file @require-mysql Scenario: Configure with database credentials using socket path - Given a WP install + Given an empty directory + And WP files + And a find-socket.php file: + """ + Date: Fri, 10 Nov 2023 11:22:27 -0800 Subject: [PATCH 07/34] Verify STDOUT is not empty --- features/config-create.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 96be4708..820e6570 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -177,8 +177,9 @@ Feature: Create a wp-config file } """ - When I run `#!/usr/bin/env php find-socket.php` + When I run `php find-socket.php` Then save STDOUT as {SOCKET} + And STDOUT should not be empty When I run `wp config create {CORE_CONFIG_SETTINGS} --dbhost={SOCKET}` Then the wp-config.php file should contain: From 7ebb9de1886cdbccb9fcce10937a24e902f86ccc Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Mon, 13 Nov 2023 10:14:49 +0100 Subject: [PATCH 08/34] Adjust accepted socket path format to include the host --- features/config-create.feature | 4 ++-- src/Config_Command.php | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 820e6570..d846682c 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,10 +181,10 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `wp config create {CORE_CONFIG_SETTINGS} --dbhost={SOCKET}` + When I run `wp config create {CORE_CONFIG_SETTINGS} --dbhost=localhost:{SOCKET}` Then the wp-config.php file should contain: """ - define( 'DB_HOST', '{SOCKET}' ); + define( 'DB_HOST', 'localhost:{SOCKET}' ); """ @require-php-7.0 diff --git a/src/Config_Command.php b/src/Config_Command.php index a1b00831..1d23a28e 100644 --- a/src/Config_Command.php +++ b/src/Config_Command.php @@ -163,12 +163,21 @@ public function create( $_, $assoc_args ) { $mysql = mysqli_init(); mysqli_report( MYSQLI_REPORT_STRICT ); try { - if ( file_exists( $assoc_args['dbhost'] ) ) { + // Accept similar format to one used by parse_db_host() e.g. 'localhost:/tmp/mysql.sock' + $socket = ''; + $host = $assoc_args['dbhost']; + $socket_pos = strpos( $host, ':/' ); + if ( false !== $socket_pos ) { + $socket = substr( $host, $socket_pos + 1 ); + $host = substr( $host, 0, $socket_pos ); + } + + if ( file_exists( $socket ) ) { // If dbhost is a path to a socket - mysqli_real_connect( $mysql, null, $assoc_args['dbuser'], $assoc_args['dbpass'], null, null, $assoc_args['dbhost'] ); + mysqli_real_connect( $mysql, null, $assoc_args['dbuser'], $assoc_args['dbpass'], null, null, $socket ); } else { // If dbhost is a hostname or IP address - mysqli_real_connect( $mysql, $assoc_args['dbhost'], $assoc_args['dbuser'], $assoc_args['dbpass'] ); + mysqli_real_connect( $mysql, $host, $assoc_args['dbuser'], $assoc_args['dbpass'] ); } } catch ( mysqli_sql_exception $exception ) { WP_CLI::error( 'Database connection error (' . $exception->getCode() . ') ' . $exception->getMessage() ); From 3a99ee924413bc4c547c192c2892f84dc1deb5bb Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Mon, 13 Nov 2023 10:38:03 +0100 Subject: [PATCH 09/34] Use individual DB variables to avoid defining host twice --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index d846682c..f0bfae17 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,7 +181,7 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `wp config create {CORE_CONFIG_SETTINGS} --dbhost=localhost:{SOCKET}` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost=localhost:{SOCKET}` Then the wp-config.php file should contain: """ define( 'DB_HOST', 'localhost:{SOCKET}' ); From f23ed8bf83e2b7de3be3ff1850a130b836b21304 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 15:29:11 +0000 Subject: [PATCH 10/34] Add quotes to DBHOST argument --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index f0bfae17..87133123 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,7 +181,7 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost=localhost:{SOCKET}` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` Then the wp-config.php file should contain: """ define( 'DB_HOST', 'localhost:{SOCKET}' ); From 63cc209d59b1cc1796eb5e8175bf88571f833b16 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 15:36:38 +0000 Subject: [PATCH 11/34] Try preparing the tests against the socket --- features/config-create.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/config-create.feature b/features/config-create.feature index 87133123..9c90981b 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,6 +181,12 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty + When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} composer prepare-tests` + Then STDOUT should contain: + """ + Detected MySQL + """ + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` Then the wp-config.php file should contain: """ From e9264e5868da2bc82f1a423d58b7d7ebe1fb98ad Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 15:51:26 +0000 Subject: [PATCH 12/34] Try using an IP address instead of localhost --- features/config-create.feature | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 9c90981b..8b160c00 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,16 +181,10 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} composer prepare-tests` - Then STDOUT should contain: - """ - Detected MySQL - """ - - When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='127.0.0.1:{SOCKET}'` Then the wp-config.php file should contain: """ - define( 'DB_HOST', 'localhost:{SOCKET}' ); + define( 'DB_HOST', '127.0.0.1:{SOCKET}' ); """ @require-php-7.0 From 219fd4f48f4003904e86cbd14fa73d1ebdb89f74 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 16:41:17 +0000 Subject: [PATCH 13/34] Revert IP address back to localhost --- features/config-create.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 8b160c00..87133123 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,10 +181,10 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='127.0.0.1:{SOCKET}'` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` Then the wp-config.php file should contain: """ - define( 'DB_HOST', '127.0.0.1:{SOCKET}' ); + define( 'DB_HOST', 'localhost:{SOCKET}' ); """ @require-php-7.0 From da3b0840243cade98197bf6b3270dd26fe339144 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 16:41:29 +0000 Subject: [PATCH 14/34] Ensure latest wp-cli-tests is pulled in --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1147d983..5470086d 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "wp-cli/db-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^4" + "wp-cli/wp-cli-tests": "^4.2.5" }, "config": { "process-timeout": 7200, From f233cbfeedeaf1b463befe8a8e7780635feae449 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 16:43:14 +0000 Subject: [PATCH 15/34] Prepare tests upfront --- features/config-create.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/config-create.feature b/features/config-create.feature index 87133123..2b3b3146 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,6 +181,12 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty + When I run `WP_CLI_TEST_DBHOST={SOCKET} vendor/bin/install-package-tests` + Then STDOUT should contain: + """ + Detected MySQL + """ + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` Then the wp-config.php file should contain: """ From 96ee8985ab2df8650074b22dec695a11542dca87 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 16:47:30 +0000 Subject: [PATCH 16/34] Use RUN_DIR variable --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 2b3b3146..c7940a27 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,7 +181,7 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `WP_CLI_TEST_DBHOST={SOCKET} vendor/bin/install-package-tests` + When I run `WP_CLI_TEST_DBHOST={SOCKET} {RUN_DIR}/vendor/bin/install-package-tests` Then STDOUT should contain: """ Detected MySQL From 83cf9ec0fadca55f23643871a28059866d533ccd Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 17:09:20 +0000 Subject: [PATCH 17/34] Download install-package-tests manually --- features/config-create.feature | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index c7940a27..f477f70d 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -181,7 +181,16 @@ Feature: Create a wp-config file Then save STDOUT as {SOCKET} And STDOUT should not be empty - When I run `WP_CLI_TEST_DBHOST={SOCKET} {RUN_DIR}/vendor/bin/install-package-tests` + When I try `wget -O {RUN_DIR}/install-package-tests https://raw.githubusercontent.com/wp-cli/wp-cli-tests/main/bin/install-package-tests` + Then STDERR should contain: + """ + install-package-tests' saved + """ + + When I run `chmod +x {RUN_DIR}/install-package-tests` + Then STDERR should be empty + + When I run `WP_CLI_TEST_DBHOST={SOCKET} {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From 933f20fd84be5cdc17360060fed1ecdc5f3fb542 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 17:19:43 +0000 Subject: [PATCH 18/34] Add missing host --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index f477f70d..82f1fc4d 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -190,7 +190,7 @@ Feature: Create a wp-config file When I run `chmod +x {RUN_DIR}/install-package-tests` Then STDERR should be empty - When I run `WP_CLI_TEST_DBHOST={SOCKET} {RUN_DIR}/install-package-tests` + When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From eea7a6aa62352b146b27e9e33d8986f0a106b41b Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 17:58:00 +0000 Subject: [PATCH 19/34] Try using IP address instead of localhost --- features/config-create.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 82f1fc4d..bdc221c0 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -190,16 +190,16 @@ Feature: Create a wp-config file When I run `chmod +x {RUN_DIR}/install-package-tests` Then STDERR should be empty - When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} {RUN_DIR}/install-package-tests` + When I run `WP_CLI_TEST_DBHOST=127.0.0.1:{SOCKET} {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL """ - When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='127.0.0.1:{SOCKET}'` Then the wp-config.php file should contain: """ - define( 'DB_HOST', 'localhost:{SOCKET}' ); + define( 'DB_HOST', '127.0.0.1:{SOCKET}' ); """ @require-php-7.0 From d9517e694b6bddb4e8db2ef6d6c1187df9e019e6 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 19:05:30 +0000 Subject: [PATCH 20/34] Bump required wp-cli-tests version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5470086d..04147cfb 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "wp-cli/db-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^4.2.5" + "wp-cli/wp-cli-tests": "^4.2.6" }, "config": { "process-timeout": 7200, From c4a6ee580e3da92e96d143fd5141929cd1bc51f8 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 18 Dec 2023 19:20:24 +0000 Subject: [PATCH 21/34] Socket protocol only works with localhost --- features/config-create.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index bdc221c0..82f1fc4d 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -190,16 +190,16 @@ Feature: Create a wp-config file When I run `chmod +x {RUN_DIR}/install-package-tests` Then STDERR should be empty - When I run `WP_CLI_TEST_DBHOST=127.0.0.1:{SOCKET} {RUN_DIR}/install-package-tests` + When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL """ - When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='127.0.0.1:{SOCKET}'` + When I run `wp config create --dbname='{DB_NAME}' --dbuser='{DB_USER}' --dbpass='{DB_PASSWORD}' --dbhost='localhost:{SOCKET}'` Then the wp-config.php file should contain: """ - define( 'DB_HOST', '127.0.0.1:{SOCKET}' ); + define( 'DB_HOST', 'localhost:{SOCKET}' ); """ @require-php-7.0 From 700da259401c04d766f0edec3b9af6e4d39aec77 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 19 Dec 2023 09:55:44 +0000 Subject: [PATCH 22/34] Add root password --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 82f1fc4d..d9aa9e3a 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -190,7 +190,7 @@ Feature: Create a wp-config file When I run `chmod +x {RUN_DIR}/install-package-tests` Then STDERR should be empty - When I run `WP_CLI_TEST_DBHOST=localhost:{SOCKET} {RUN_DIR}/install-package-tests` + When I run `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' WP_CLI_TEST_DBROOTPASS='root' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From fc6207eaf96f55c4d367e302b727ca46b20b5e1d Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 19 Dec 2023 09:59:43 +0000 Subject: [PATCH 23/34] Account for warnings --- features/config-create.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index d9aa9e3a..a73d8f53 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -190,7 +190,8 @@ Feature: Create a wp-config file When I run `chmod +x {RUN_DIR}/install-package-tests` Then STDERR should be empty - When I run `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' WP_CLI_TEST_DBROOTPASS='root' {RUN_DIR}/install-package-tests` + # We try to account for the warnings we get for passing the password on the command line. + When I try `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' WP_CLI_TEST_DBROOTPASS='root' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From 0f096aad20778d5fb1445480f79ae6cdee308e2e Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 19 Dec 2023 12:15:59 +0000 Subject: [PATCH 24/34] Remove password for bundled MySQL --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index a73d8f53..2e6b6d83 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -191,7 +191,7 @@ Feature: Create a wp-config file Then STDERR should be empty # We try to account for the warnings we get for passing the password on the command line. - When I try `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' WP_CLI_TEST_DBROOTPASS='root' {RUN_DIR}/install-package-tests` + When I try `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From 490535c74c0acf9262054b7900c8b77984c25ab0 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 19 Dec 2023 13:33:39 +0000 Subject: [PATCH 25/34] Use custom filename first to disambiguate --- features/config-create.feature | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 2e6b6d83..3c8f820a 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -167,7 +167,9 @@ Feature: Create a wp-config file And a find-socket.php file: """ Date: Wed, 20 Dec 2023 16:19:46 +0000 Subject: [PATCH 26/34] Use latest wp-cli-tests --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 04147cfb..d49421c4 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "wp-cli/db-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^4.2.6" + "wp-cli/wp-cli-tests": "^4.2.7" }, "config": { "process-timeout": 7200, From 90d0465ca6e5e344efed48a53d6c4c152baddea5 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 20 Dec 2023 17:15:38 +0000 Subject: [PATCH 27/34] Adapt socket test --- features/config-create.feature | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 3c8f820a..ea6d639d 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -167,16 +167,22 @@ Feature: Create a wp-config file And a find-socket.php file: """ Date: Wed, 20 Dec 2023 17:30:06 +0000 Subject: [PATCH 28/34] Remove vendor folder socket dir --- features/config-create.feature | 2 -- 1 file changed, 2 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index ea6d639d..12469f28 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -168,10 +168,8 @@ Feature: Create a wp-config file """ Date: Wed, 20 Dec 2023 17:42:48 +0000 Subject: [PATCH 29/34] Add comment to test script --- features/config-create.feature | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features/config-create.feature b/features/config-create.feature index 12469f28..09c6f0f8 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -167,6 +167,8 @@ Feature: Create a wp-config file And a find-socket.php file: """ Date: Wed, 20 Dec 2023 17:54:14 +0000 Subject: [PATCH 30/34] Do not check the env-provided socket for validity --- features/config-create.feature | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/features/config-create.feature b/features/config-create.feature index 09c6f0f8..8e58f613 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -168,10 +168,12 @@ Feature: Create a wp-config file """ Date: Wed, 20 Dec 2023 18:15:54 +0000 Subject: [PATCH 31/34] Use Behat internal var DB_SOCKET --- composer.json | 2 +- features/config-create.feature | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d49421c4..fd552c60 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "wp-cli/db-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^4.2.7" + "wp-cli/wp-cli-tests": "^4.2.8" }, "config": { "process-timeout": 7200, diff --git a/features/config-create.feature b/features/config-create.feature index 8e58f613..1ff54a14 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -173,7 +173,10 @@ Feature: Create a wp-config file echo getenv( 'WP_CLI_TEST_DBSOCKET' ); exit(0); } + // From within Behat, the WP_CLI_TEST_DBSOCKET will be mapped to the internal + // DB_SOCKET variable, as Behat pushes a new environment context. $locations = [ + '{DB_SOCKET}', '/var/run/mysqld/mysqld.sock', '/tmp/mysql.sock', ]; From aa82b62d24d5efcb5004e96cd98500ad810c9d40 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 21 Dec 2023 00:32:44 +0000 Subject: [PATCH 32/34] Add MYSQL_HOST for socket connection --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 1ff54a14..f5145b34 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -204,7 +204,7 @@ Feature: Create a wp-config file Then STDERR should be empty # We try to account for the warnings we get for passing the password on the command line. - When I try `WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` + When I try `MYSQL_HOST='localhost:{SOCKET}' WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From c8e1c332ebb4f8546eff9714cc9cf0988d7356d5 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 21 Dec 2023 09:06:50 +0000 Subject: [PATCH 33/34] Simplify MYSQL_HOST --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index f5145b34..43e663e8 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -204,7 +204,7 @@ Feature: Create a wp-config file Then STDERR should be empty # We try to account for the warnings we get for passing the password on the command line. - When I try `MYSQL_HOST='localhost:{SOCKET}' WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` + When I try `MYSQL_HOST=localhost WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL From 10677fe05442c70f5ab835936c7d1a2ef405eecf Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 21 Dec 2023 09:36:40 +0000 Subject: [PATCH 34/34] Add root password --- features/config-create.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/config-create.feature b/features/config-create.feature index 43e663e8..bcbcf323 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -204,7 +204,7 @@ Feature: Create a wp-config file Then STDERR should be empty # We try to account for the warnings we get for passing the password on the command line. - When I try `MYSQL_HOST=localhost WP_CLI_TEST_DBHOST='localhost:{SOCKET}' {RUN_DIR}/install-package-tests` + When I try `MYSQL_HOST=localhost WP_CLI_TEST_DBHOST='localhost:{SOCKET}' WP_CLI_TEST_DBROOTPASS='root' {RUN_DIR}/install-package-tests` Then STDOUT should contain: """ Detected MySQL