From 1175e48f708961054029a556afaf8979e30ab512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Wed, 23 Oct 2024 13:06:33 +0200 Subject: [PATCH 1/4] Update dev system to 2.4.7-p2 --- .ddev/config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 26aee9ee..d0b472b5 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -18,7 +18,7 @@ hooks: use_dns_when_possible: true composer_version: 2.2.17 web_environment: - - MAGERUN_SETUP_TEST_DEFAULT_MAGENTO_VERSION=2.4.7 + - MAGERUN_SETUP_TEST_DEFAULT_MAGENTO_VERSION=2.4.7-p2 - N98_MAGERUN2_BIN=/var/www/html/bin/n98-magerun2 nodejs_version: "16" @@ -58,7 +58,7 @@ nodejs_version: "16" # "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better, # as leaving xhprof enabled all the time is a big performance hit. -# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn +# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn # timezone: Europe/Berlin # This is the timezone used in the containers and by PHP; @@ -100,7 +100,7 @@ nodejs_version: "16" # Please take care with this because it can cause great confusion. # upload_dirs: "custom/upload/dir" -# +# # upload_dirs: # - custom/upload/dir # - ../private From d51383f548ed651a2998e1dd7692666b1b03e53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Wed, 23 Oct 2024 13:07:01 +0200 Subject: [PATCH 2/4] Docker does not want a version anymore --- .ddev/docker-compose.elastic.yaml | 3 +-- .ddev/docker-compose.magento-volumes.yaml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.ddev/docker-compose.elastic.yaml b/.ddev/docker-compose.elastic.yaml index 59ea270e..99753286 100644 --- a/.ddev/docker-compose.elastic.yaml +++ b/.ddev/docker-compose.elastic.yaml @@ -1,4 +1,3 @@ -version: '3.6' services: # see: https://github.com/drud/ddev-contrib/blob/master/docker-compose-services/elasticsearch/docker-compose.elasticsearch.yaml @@ -28,4 +27,4 @@ services: - elasticsearch:elasticsearch volumes: - elasticsearch: \ No newline at end of file + elasticsearch: diff --git a/.ddev/docker-compose.magento-volumes.yaml b/.ddev/docker-compose.magento-volumes.yaml index 3dd6b004..4752e8bd 100644 --- a/.ddev/docker-compose.magento-volumes.yaml +++ b/.ddev/docker-compose.magento-volumes.yaml @@ -1,4 +1,3 @@ -version: '3.6' services: web: volumes: From 7f5c1291ac48db0faf9d19a4d5e2b1a83b25fe82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Wed, 23 Oct 2024 13:07:10 +0200 Subject: [PATCH 3/4] Fix typo --- src/N98/Magento/Command/Database/DumpCommand.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/Database/DumpCommand.php b/src/N98/Magento/Command/Database/DumpCommand.php index 78e2a14e..5af22df3 100644 --- a/src/N98/Magento/Command/Database/DumpCommand.php +++ b/src/N98/Magento/Command/Database/DumpCommand.php @@ -3,6 +3,7 @@ namespace N98\Magento\Command\Database; use InvalidArgumentException; +use Magento\Framework\Exception\FileSystemException; use N98\Magento\Command\Database\Compressor\Compressor; use N98\Util\Console\Enabler; use N98\Util\Console\Helper\DatabaseHelper; @@ -207,7 +208,7 @@ public function getTableDefinitionHelp() Separate each table to strip by a space. You can use wildcards like * and ? in the table names to strip multiple - tables. In addition you can specify pre-defined table groups, that start + tables. In addition, you can specify pre-defined table groups, that start with an @ symbol. Example: "dataflow_batch_export unimportant_module_* @log" @@ -263,7 +264,7 @@ public function getHelp() * @param OutputInterface $output * * @return int - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -290,7 +291,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param InputInterface $input * @param OutputInterface $output * @return Execs - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function createExecs(InputInterface $input, OutputInterface $output) { @@ -432,7 +433,7 @@ private function runExec($command, InputInterface $input, OutputInterface $outpu * @param InputInterface $input * @param OutputInterface $output * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function stripTables(InputInterface $input, OutputInterface $output) { @@ -455,7 +456,7 @@ private function stripTables(InputInterface $input, OutputInterface $output) * @param InputInterface $input * @param OutputInterface $output * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function excludeTables(InputInterface $input, OutputInterface $output) { @@ -487,7 +488,7 @@ private function excludeTables(InputInterface $input, OutputInterface $output) /** * @param string $list space separated list of tables * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function resolveDatabaseTables($list) { From 470541c23132be4f0a00d72dba5a1e87773cc70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Wed, 23 Oct 2024 13:07:38 +0200 Subject: [PATCH 4/4] Some mariadb client tools do not support --ssl-mode option --- .../Util/Console/Helper/DatabaseHelper.php | 74 ++++++++++++------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/src/N98/Util/Console/Helper/DatabaseHelper.php b/src/N98/Util/Console/Helper/DatabaseHelper.php index 2f5b2926..8ff743cc 100644 --- a/src/N98/Util/Console/Helper/DatabaseHelper.php +++ b/src/N98/Util/Console/Helper/DatabaseHelper.php @@ -3,6 +3,8 @@ namespace N98\Util\Console\Helper; use InvalidArgumentException; +use Magento\Framework\Exception\FileSystemException; +use N98\Util\Exec; use PDO; use PDOException; use PDOStatement; @@ -57,7 +59,7 @@ public function setConnectionType($connectionType) * @param OutputInterface|null $output * * @throws RuntimeException - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException * @return void */ public function detectDbSettings(OutputInterface $output) @@ -113,7 +115,7 @@ public function detectDbSettings(OutputInterface $output) * @param bool $reconnect = false * @return PDO * @throws RuntimeException pdo mysql extension is not installed - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getConnection(OutputInterface $output = null, bool $reconnect = false) { @@ -160,7 +162,7 @@ public function getConnection(OutputInterface $output = null, bool $reconnect = $this->dbSettings['password'], $connectionOptions ); - $this->_connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /** @link http://bugs.mysql.com/bug.php?id=18551 */ $this->_connection->query("SET SQL_MODE=''"); @@ -201,7 +203,7 @@ public function getTableName($tableName) * * @see Zend_Db_Adapter_Pdo_Abstract * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function dsn() { @@ -240,7 +242,7 @@ public function dsn() * @param string $privilege * * @return bool - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function mysqlUserHasPrivilege($privilege) { @@ -258,9 +260,31 @@ public function mysqlUserHasPrivilege($privilege) return false; } + /** + * Check if the toolstack is using mariadb + * + * @return bool + */ + public function isMariaDbClientToolUsed(): bool + { + Exec::run('mysqldump --help', $output, $exitCode); + return strpos($output, 'MariaDB') !== false; + } + + /** + * Some versions of mysqldump shipped by MariaDB are not able to handle the --ssl-mode option + * + * @return bool + */ + public function isSslModeOptionSupported(): bool + { + Exec::run('mysqldump --help', $output, $exitCode); + return strpos($output, '--ssl-mode') !== false; + } + /** * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getMysqlClientToolConnectionString() { @@ -303,15 +327,15 @@ public function getMysqlClientToolConnectionString() } } + $isSslModeSupported = $this->isSslModeOptionSupported(); + // see https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode - if (array_key_exists(PDO::MYSQL_ATTR_SSL_CA, $connectionOptions)) { - if (!array_key_exists(PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT, $connectionOptions) - || $connectionOptions[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] - ) { - $sslOptions[] = '--ssl-mode=VERIFY_CA'; - } else { - $sslOptions[] = '--ssl-mode=REQUIRED'; - } + // see https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode + if ($isSslModeSupported && array_key_exists(PDO::MYSQL_ATTR_SSL_CA, $connectionOptions)) { + $sslOptions[] = !array_key_exists(PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT, $connectionOptions) + || $connectionOptions[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] + ? '--ssl-mode=VERIFY_CA' + : '--ssl-mode=REQUIRED'; } $string .= ' ' . implode(' ', $sslOptions) @@ -333,7 +357,7 @@ public function getMysqlClientToolConnectionString() * @param string $variable * * @return bool|array returns array on success, false on failure - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getMysqlVariableValue($variable) { @@ -363,7 +387,7 @@ public function getMysqlVariableValue($variable) * @return string variable value, null if variable was not defined * @throws RuntimeException in case a system variable is unknown (SQLSTATE[HY000]: 1193: Unknown system variable * 'nonexistent') - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getMysqlVariable($name, $type = null) { @@ -455,7 +479,7 @@ public function getTableDefinitions(array $commandConfig) * * @return array * @throws RuntimeException - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function resolveTables(array $list, array $definitions = [], array $resolved = []) { @@ -566,7 +590,7 @@ private function resolveTablesArray(array $carry = null, $item = null) * * @return array * @throws RuntimeException - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getTables($withoutPrefix = null) { @@ -658,7 +682,7 @@ private function quoteLike($string, $escape = '=') * @param bool $withoutPrefix * * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getTablesStatus($withoutPrefix = false) { @@ -719,7 +743,7 @@ public function getName() /** * @param OutputInterface $output - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function dropDatabase(OutputInterface $output) { @@ -731,7 +755,7 @@ public function dropDatabase(OutputInterface $output) /** * @param OutputInterface $output - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function dropTables(OutputInterface $output) { @@ -749,7 +773,7 @@ public function dropTables(OutputInterface $output) /** * @param OutputInterface $output - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function createDatabase(OutputInterface $output) { @@ -764,7 +788,7 @@ public function createDatabase(OutputInterface $output) * @param string|null $variable [optional] * * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function runShowCommand($command, $variable = null) { @@ -800,7 +824,7 @@ private function runShowCommand($command, $variable = null) * @param string|null $variable [optional] * * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getGlobalVariables($variable = null) { @@ -811,7 +835,7 @@ public function getGlobalVariables($variable = null) * @param string|null $variable [optional] * * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getGlobalStatus($variable = null) {