diff --git a/.gitignore b/.gitignore index a3b63ba..b02912e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /composer.phar /composer.lock /auth.json +/codeception.yml +/_workdir diff --git a/.travis.yml b/.travis.yml index 1104c7c..55fb2ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,68 @@ dist: xenial git: depth: false +addons: + hosts: + - magento2.docker + +services: + - docker + language: php -php: - - '7.0' - - '7.1' - - '7.2' - - '7.3' -install: composer update +stages: + - static-unit + - test + +jobs: + include: + - stage: static-unit + script: ./tests/travis/static-unit.sh; + php: '7.0' + env: + - TEST_SUITE=static-unit + - script: ./tests/travis/static-unit.sh; + php: '7.1' + env: + - TEST_SUITE=static-unit + - script: ./tests/travis/static-unit.sh; + php: '7.2' + env: + - TEST_SUITE=static-unit + - script: ./tests/travis/static-unit.sh; + php: '7.3' + env: + - TEST_SUITE=static-unit + - stage: test + php: '7.1' + env: + - TEST_SUITE=functional-ee + - php: '7.2' + env: + - TEST_SUITE=functional-ee + - php: '7.3' + env: + - TEST_SUITE=functional-ee + - php: '7.1' + env: + - TEST_SUITE=functional-ce + - php: '7.2' + env: + - TEST_SUITE=functional-ce + - php: '7.3' + env: + - TEST_SUITE=functional-ce + +install: + - composer config http-basic.repo.magento.com ${REPO_USERNAME_CE} ${REPO_PASSWORD_CE} + - composer config github-oauth.github.com ${GITHUB_TOKEN} + - if [ -n "${MCD_VERSION}" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then composer config repositories.mcd git git@github.com:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi; + - composer update -n --no-suggest + +before_script: + - sudo sysctl -w vm.max_map_count=262144 + - if [ $TEST_SUITE == "functional-ce" ]; then cp codeception.dist.yml codeception.yml && sed -i "s/REPO_USERNAME/REPO_USERNAME_CE/" codeception.yml && sed -i "s/REPO_PASSWORD/REPO_PASSWORD_CE/" codeception.yml; fi; script: - - ./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n - - ./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml - - ./vendor/bin/phpunit --configuration ./tests/unit + - if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional-ee" ]; then ./tests/travis/functional-ee.sh; fi; + - if [ $TEST_SUITE == "functional-ce" ]; then ./tests/travis/functional-ce.sh; fi; diff --git a/codeception.dist.yml b/codeception.dist.yml new file mode 100644 index 0000000..710cb34 --- /dev/null +++ b/codeception.dist.yml @@ -0,0 +1,37 @@ +paths: + tests: src/Test/Functional + output: tests/functional/_output + data: tests/functional/_data + support: vendor/magento/magento-cloud-docker/tests/functional/_support +actor_suffix: Tester +settings: + colors: true +extensions: + enabled: + - Codeception\Extension\RunFailed + - Codeception\Extension\FailedInfo +params: + - vendor/magento/magento-cloud-docker/tests/functional/configuration.dist.yml + - env +modules: + config: + Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure: + template_repo: "https://github.com/magento/magento-cloud.git" + mcd_repo: "https://github.com/magento/magento-cloud-docker.git" + mcc_repo: "https://github.com/magento/magento-cloud-components.git" + mcp_repo: "https://github.com/magento/magento-cloud-patches.git" + composer_magento_username: "%REPO_USERNAME%" + composer_magento_password: "%REPO_PASSWORD%" + composer_github_token: "%GITHUB_TOKEN%" + printOutput: false + Magento\CloudDocker\Test\Functional\Codeception\Docker: + system_magento_dir: "%Magento.docker.settings.system.magento_dir%" + printOutput: false + PhpBrowser: + url: "%Magento.docker.settings.env.url.base%" + Magento\CloudDocker\Test\Functional\Codeception\MagentoDb: + dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%" + user: "%Magento.docker.settings.db.username%" + password: "%Magento.docker.settings.db.password%" + exposed_port: "%Magento.docker.settings.db.port%" + reconnect: true diff --git a/composer.json b/composer.json index b5dda5e..d0aabb1 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,8 @@ "symfony/process": "^2.1||^4.1" }, "require-dev": { + "codeception/codeception": "^2.5.3", + "consolidation/robo": "^1.2", "phpmd/phpmd": "@stable", "phpunit/phpunit": "^6.2", "squizlabs/php_codesniffer": "^3.0" @@ -24,7 +26,8 @@ ], "autoload": { "psr-4": { - "Magento\\CloudPatches\\": "src/" + "Magento\\CloudPatches\\": "src/", + "Magento\\CloudPatches\\Test\\Functional\\": "tests/functional/" } }, "scripts": { diff --git a/patches.json b/patches.json index 09d0fbc..4ba0374 100644 --- a/patches.json +++ b/patches.json @@ -78,9 +78,6 @@ "2.2.0 - 2.2.3": "SET-36__fix_oom_during_customer_import__2.2.0.patch", "2.2.4": "SET-36__fix_oom_during_customer_import__2.2.4.patch" }, - "Add PayPal and Braintree TPV codes on checkout": { - "~2.1.8": "MAGETWO-53941__fix_enterprise_payment_codes__2.1.8.patch" - }, "Fix Mview on staging environments": { "2.1.4": "MAGETWO-84444__fix_mview_on_staging__2.1.4.patch", "2.1.5 - 2.1.9": "MAGETWO-84444__fix_mview_on_staging__2.1.5.patch", @@ -107,19 +104,14 @@ "Unlock locale editing when SCD on demand is enabled": { "2.2.0 - 2.2.5": "MAGECLOUD-2159__unlock_locale_editing_when_scd_on_demand__2.2.0.patch" }, - "Allow DB dumps done with the support module to complete": { - "2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch" - }, "Write Logs for Failed Process of Generating Factories in Extensions": { "2.2.0 - 2.2.5": "MAGECLOUD-2209__write_logs_for_failed_process_of_generating_factories_in_extensions__2.2.0.patch" }, "Fix Problems with Consumer Runners on Cloud Clusters": { - "2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch", - "2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch", - "2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch", - "2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch", - "2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch", - "2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch", + "2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch", + "2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch", + "2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch", + "2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch", "2.3.0": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.0.patch", ">=2.3.1 <2.3.3": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.1.patch" }, @@ -186,7 +178,6 @@ ">=2.3.0 <2.3.3": "MAGECLOUD-3806__error_code_fix_for_setup_upgrade__2.3.0.patch" }, "Re-work consumers to terminate as soon as there is nothing left to process": { - "2.2.0 - 2.3.1": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch", ">=2.3.2 <2.3.4": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.3.2.patch" }, "Backward Compatibility of new Mail Interfaces": { @@ -224,9 +215,6 @@ "2.2.0 - 2.2.8": "PRODSECBUG-2432__admin_path_disclosure_bug__2.2.0.patch", "2.3.0 - 2.3.1": "PRODSECBUG-2432__admin_path_disclosure_bug__2.3.0.patch" }, - "Transaction MD5 hash field is removed by Authorize.net": { - "2.2.0 - 2.2.7": "MAGETWO-98129__transaction_field_is_removed_by_authorize_net__2.2.0.patch" - }, "Customer attributes issue": { "2.2.6": "MAGETWO-95591__customer_attributes_issue__2.2.6.patch" }, @@ -239,12 +227,38 @@ "Fix for multi-site configuration issue": { "2.2.4": "MAGETWO-92926__fix_for_multi-site_configuration_issue__2.2.4.patch" }, - "Fix PayPal issue with region": { - "2.3.4": "MC-31387__fix_paypal_issue_with_region__2.3.4.patch" - }, "FPC is getting disabled during deployments": { ">=2.3.2 <2.3.5": "MAGECLOUD-5069__fpc_is_getting_disabled_during_deployments__2.3.2.patch", ">=2.3.5 <2.4.0": "MAGECLOUD-5069__fpc_is_getting_disabled_during_deployments__2.3.5.patch" + }, + "Hold deployment config after reading from file": { + ">=2.3.3 <2.3.6": "MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch" + }, + "Pagination Not working - product_list_limit=all": { + ">=2.3.2 <2.3.4": "MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.2.patch", + ">=2.3.4 <2.4.0": "MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.4.patch" + }, + "Sitemap Generation Warnings": { + ">=2.3.0 <2.3.2": "MCLOUD-3025__sitemap_generation_warnings__2.3.0.patch", + ">=2.3.2 <2.3.5": "MCLOUD-3025__sitemap_generation_warnings__2.3.3.patch" + } + }, + "magento/module-paypal": { + "Add PayPal TPV codes on checkout": { + "~100.1.6": "MAGETWO-53941__fix_enterprise_paypal_codes__100.1.6.patch" + }, + "Fix PayPal issue with region": { + "100.3.4": "MC-31387__fix_paypal_issue_with_region__100.3.4.patch" + } + }, + "magento/module-authorizenet": { + "Transaction MD5 hash field is removed by Authorize.net": { + "100.2.0 - 100.2.3": "MAGETWO-98129__transaction_field_is_removed_by_authorize_net__100.2.0.patch" + } + }, + "magento/module-braintree": { + "Add Braintree TPV codes on checkout": { + "~100.1.6": "MAGETWO-53941__fix_enterprise_braintree_code__100.1.6.patch" } }, "monolog/monolog": { @@ -303,6 +317,20 @@ "2.3.2": "PB-320__fix_pagebuilder_module__2.3.2.patch", ">=2.3.2-p1 <2.3.3": "PB-322__fix_pagebuilder_module__2.3.2-p1.patch", "2.3.3": "PB-323__fix_pagebuilder_module__2.3.3.patch" + }, + "Allow DB dumps done with the support module to complete": { + "2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch" + }, + "Fix Problems with Consumer Runners on Cloud Clusters": { + "2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch", + "2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch", + "2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch", + "2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch", + "2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch", + "2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch" + }, + "Re-work consumers to terminate as soon as there is nothing left to process": { + ">=2.2.0 <2.3.2": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch" } } } diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch new file mode 100644 index 0000000..f1aae1c --- /dev/null +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch @@ -0,0 +1,139 @@ +diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php +--- a/vendor/magento/framework/Lock/Backend/Database.php ++++ b/vendor/magento/framework/Lock/Backend/Database.php +@@ -3,8 +3,8 @@ + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +- + declare(strict_types=1); ++ + namespace Magento\Framework\Lock\Backend; + + use Magento\Framework\App\DeploymentConfig; +@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException; + use Magento\Framework\Exception\InputException; + use Magento\Framework\Phrase; + ++/** ++ * Implementation of the lock manager on the basis of MySQL. ++ */ + class Database implements \Magento\Framework\Lock\LockManagerInterface + { +- /** @var ResourceConnection */ ++ /** ++ * Max time for lock is 1 week ++ * ++ * MariaDB does not support negative timeout value to get infinite timeout, ++ * so we set 1 week for lock timeout ++ */ ++ const MAX_LOCK_TIME = 604800; ++ ++ /** ++ * @var ResourceConnection ++ */ + private $resource; + +- /** @var DeploymentConfig */ ++ /** ++ * @var DeploymentConfig ++ */ + private $deploymentConfig; + +- /** @var string Lock prefix */ ++ /** ++ * @var string Lock prefix ++ */ + private $prefix; + +- /** @var string|false Holds current lock name if set, otherwise false */ ++ /** ++ * @var string|false Holds current lock name if set, otherwise false ++ */ + private $currentLock = false; + ++ /** ++ * @param ResourceConnection $resource ++ * @param DeploymentConfig $deploymentConfig ++ * @param string|null $prefix ++ */ + public function __construct( + ResourceConnection $resource, + DeploymentConfig $deploymentConfig, +@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @return bool + * @throws InputException + * @throws AlreadyExistsException ++ * @throws \Zend_Db_Statement_Exception + */ + public function lock(string $name, int $timeout = -1): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; + $name = $this->addPrefix($name); + + /** +@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + if ($this->currentLock) { + throw new AlreadyExistsException( + new Phrase( +- 'Current connection is already holding lock for $1, only single lock allowed', ++ 'Current connection is already holding lock for %1, only single lock allowed', + [$this->currentLock] + ) + ); +@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + + $result = (bool)$this->resource->getConnection()->query( + "SELECT GET_LOCK(?, ?);", +- [(string)$name, (int)$timeout] ++ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] + )->fetchColumn(); + + if ($result === true) { +@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function unlock(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; ++ + $name = $this->addPrefix($name); + + $result = (bool)$this->resource->getConnection()->query( +@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function isLocked(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return false; ++ }; ++ + $name = $this->addPrefix($name); + + return (bool)$this->resource->getConnection()->query( + "SELECT IS_USED_LOCK(?);", +- [(string)$name] ++ [$name] + )->fetchColumn(); + } + +@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * Limited to 64 characters in MySQL. + * + * @param string $name +- * @return string $name ++ * @return string + * @throws InputException + */ + private function addPrefix(string $name): string diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch similarity index 77% rename from patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch rename to patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch index a10280b..4f29a56 100644 --- a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch @@ -1,142 +1,3 @@ -diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php ---- a/vendor/magento/framework/Lock/Backend/Database.php -+++ b/vendor/magento/framework/Lock/Backend/Database.php -@@ -3,8 +3,8 @@ - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -- - declare(strict_types=1); -+ - namespace Magento\Framework\Lock\Backend; - - use Magento\Framework\App\DeploymentConfig; -@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException; - use Magento\Framework\Exception\InputException; - use Magento\Framework\Phrase; - -+/** -+ * Implementation of the lock manager on the basis of MySQL. -+ */ - class Database implements \Magento\Framework\Lock\LockManagerInterface - { -- /** @var ResourceConnection */ -+ /** -+ * Max time for lock is 1 week -+ * -+ * MariaDB does not support negative timeout value to get infinite timeout, -+ * so we set 1 week for lock timeout -+ */ -+ const MAX_LOCK_TIME = 604800; -+ -+ /** -+ * @var ResourceConnection -+ */ - private $resource; - -- /** @var DeploymentConfig */ -+ /** -+ * @var DeploymentConfig -+ */ - private $deploymentConfig; - -- /** @var string Lock prefix */ -+ /** -+ * @var string Lock prefix -+ */ - private $prefix; - -- /** @var string|false Holds current lock name if set, otherwise false */ -+ /** -+ * @var string|false Holds current lock name if set, otherwise false -+ */ - private $currentLock = false; - -+ /** -+ * @param ResourceConnection $resource -+ * @param DeploymentConfig $deploymentConfig -+ * @param string|null $prefix -+ */ - public function __construct( - ResourceConnection $resource, - DeploymentConfig $deploymentConfig, -@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @return bool - * @throws InputException - * @throws AlreadyExistsException -+ * @throws \Zend_Db_Statement_Exception - */ - public function lock(string $name, int $timeout = -1): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; - $name = $this->addPrefix($name); - - /** -@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - if ($this->currentLock) { - throw new AlreadyExistsException( - new Phrase( -- 'Current connection is already holding lock for $1, only single lock allowed', -+ 'Current connection is already holding lock for %1, only single lock allowed', - [$this->currentLock] - ) - ); -@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - - $result = (bool)$this->resource->getConnection()->query( - "SELECT GET_LOCK(?, ?);", -- [(string)$name, (int)$timeout] -+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] - )->fetchColumn(); - - if ($result === true) { -@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function unlock(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; -+ - $name = $this->addPrefix($name); - - $result = (bool)$this->resource->getConnection()->query( -@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function isLocked(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return false; -+ }; -+ - $name = $this->addPrefix($name); - - return (bool)$this->resource->getConnection()->query( - "SELECT IS_USED_LOCK(?);", -- [(string)$name] -+ [$name] - )->fetchColumn(); - } - -@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * Limited to 64 characters in MySQL. - * - * @param string $name -- * @return string $name -+ * @return string - * @throws InputException - */ - private function addPrefix(string $name): string diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php --- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php +++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch new file mode 100644 index 0000000..04ff381 --- /dev/null +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch @@ -0,0 +1,137 @@ +diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php +--- a/vendor/magento/framework/Lock/Backend/Database.php ++++ b/vendor/magento/framework/Lock/Backend/Database.php +@@ -3,8 +3,8 @@ + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +- + declare(strict_types=1); ++ + namespace Magento\Framework\Lock\Backend; + + use Magento\Framework\App\DeploymentConfig; +@@ -14,23 +14,40 @@ use Magento\Framework\Exception\AlreadyExistsException; + use Magento\Framework\Exception\InputException; + use Magento\Framework\Phrase; + ++/** ++ * Implementation of the lock manager on the basis of MySQL. ++ */ + class Database implements \Magento\Framework\Lock\LockManagerInterface + { +- /** @var ResourceConnection */ ++ /** ++ * Max time for lock is 1 week ++ * ++ * MariaDB does not support negative timeout value to get infinite timeout, ++ * so we set 1 week for lock timeout ++ */ ++ const MAX_LOCK_TIME = 604800; ++ ++ /** ++ * @var ResourceConnection ++ */ + private $resource; + +- /** @var DeploymentConfig */ ++ /** ++ * @var DeploymentConfig ++ */ + private $deploymentConfig; + +- /** @var string Lock prefix */ ++ /** ++ * @var string Lock prefix ++ */ + private $prefix; + +- /** @var string|false Holds current lock name if set, otherwise false */ ++ /** ++ * @var string|false Holds current lock name if set, otherwise false ++ */ + private $currentLock = false; + + /** +- * Database constructor. +- * + * @param ResourceConnection $resource + * @param DeploymentConfig $deploymentConfig + * @param string|null $prefix +@@ -53,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @return bool + * @throws InputException + * @throws AlreadyExistsException ++ * @throws \Zend_Db_Statement_Exception + */ + public function lock(string $name, int $timeout = -1): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; + $name = $this->addPrefix($name); + + /** +@@ -66,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + if ($this->currentLock) { + throw new AlreadyExistsException( + new Phrase( +- 'Current connection is already holding lock for $1, only single lock allowed', ++ 'Current connection is already holding lock for %1, only single lock allowed', + [$this->currentLock] + ) + ); +@@ -74,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + + $result = (bool)$this->resource->getConnection()->query( + "SELECT GET_LOCK(?, ?);", +- [(string)$name, (int)$timeout] ++ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] + )->fetchColumn(); + + if ($result === true) { +@@ -90,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function unlock(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; ++ + $name = $this->addPrefix($name); + + $result = (bool)$this->resource->getConnection()->query( +@@ -113,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function isLocked(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return false; ++ }; ++ + $name = $this->addPrefix($name); + + return (bool)$this->resource->getConnection()->query( + "SELECT IS_USED_LOCK(?);", +- [(string)$name] ++ [$name] + )->fetchColumn(); + } + +@@ -130,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * Limited to 64 characters in MySQL. + * + * @param string $name +- * @return string $name ++ * @return string + * @throws InputException + */ + private function addPrefix(string $name): string diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch similarity index 78% rename from patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch rename to patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch index a4b3d37..b9d9985 100644 --- a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch @@ -1,140 +1,3 @@ -diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php ---- a/vendor/magento/framework/Lock/Backend/Database.php -+++ b/vendor/magento/framework/Lock/Backend/Database.php -@@ -3,8 +3,8 @@ - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -- - declare(strict_types=1); -+ - namespace Magento\Framework\Lock\Backend; - - use Magento\Framework\App\DeploymentConfig; -@@ -14,23 +14,40 @@ use Magento\Framework\Exception\AlreadyExistsException; - use Magento\Framework\Exception\InputException; - use Magento\Framework\Phrase; - -+/** -+ * Implementation of the lock manager on the basis of MySQL. -+ */ - class Database implements \Magento\Framework\Lock\LockManagerInterface - { -- /** @var ResourceConnection */ -+ /** -+ * Max time for lock is 1 week -+ * -+ * MariaDB does not support negative timeout value to get infinite timeout, -+ * so we set 1 week for lock timeout -+ */ -+ const MAX_LOCK_TIME = 604800; -+ -+ /** -+ * @var ResourceConnection -+ */ - private $resource; - -- /** @var DeploymentConfig */ -+ /** -+ * @var DeploymentConfig -+ */ - private $deploymentConfig; - -- /** @var string Lock prefix */ -+ /** -+ * @var string Lock prefix -+ */ - private $prefix; - -- /** @var string|false Holds current lock name if set, otherwise false */ -+ /** -+ * @var string|false Holds current lock name if set, otherwise false -+ */ - private $currentLock = false; - - /** -- * Database constructor. -- * - * @param ResourceConnection $resource - * @param DeploymentConfig $deploymentConfig - * @param string|null $prefix -@@ -53,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @return bool - * @throws InputException - * @throws AlreadyExistsException -+ * @throws \Zend_Db_Statement_Exception - */ - public function lock(string $name, int $timeout = -1): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; - $name = $this->addPrefix($name); - - /** -@@ -66,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - if ($this->currentLock) { - throw new AlreadyExistsException( - new Phrase( -- 'Current connection is already holding lock for $1, only single lock allowed', -+ 'Current connection is already holding lock for %1, only single lock allowed', - [$this->currentLock] - ) - ); -@@ -74,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - - $result = (bool)$this->resource->getConnection()->query( - "SELECT GET_LOCK(?, ?);", -- [(string)$name, (int)$timeout] -+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] - )->fetchColumn(); - - if ($result === true) { -@@ -90,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function unlock(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; -+ - $name = $this->addPrefix($name); - - $result = (bool)$this->resource->getConnection()->query( -@@ -113,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function isLocked(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return false; -+ }; -+ - $name = $this->addPrefix($name); - - return (bool)$this->resource->getConnection()->query( - "SELECT IS_USED_LOCK(?);", -- [(string)$name] -+ [$name] - )->fetchColumn(); - } - -@@ -130,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * Limited to 64 characters in MySQL. - * - * @param string $name -- * @return string $name -+ * @return string - * @throws InputException - */ - private function addPrefix(string $name): string diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php --- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php +++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch new file mode 100644 index 0000000..04ff381 --- /dev/null +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch @@ -0,0 +1,137 @@ +diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php +--- a/vendor/magento/framework/Lock/Backend/Database.php ++++ b/vendor/magento/framework/Lock/Backend/Database.php +@@ -3,8 +3,8 @@ + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +- + declare(strict_types=1); ++ + namespace Magento\Framework\Lock\Backend; + + use Magento\Framework\App\DeploymentConfig; +@@ -14,23 +14,40 @@ use Magento\Framework\Exception\AlreadyExistsException; + use Magento\Framework\Exception\InputException; + use Magento\Framework\Phrase; + ++/** ++ * Implementation of the lock manager on the basis of MySQL. ++ */ + class Database implements \Magento\Framework\Lock\LockManagerInterface + { +- /** @var ResourceConnection */ ++ /** ++ * Max time for lock is 1 week ++ * ++ * MariaDB does not support negative timeout value to get infinite timeout, ++ * so we set 1 week for lock timeout ++ */ ++ const MAX_LOCK_TIME = 604800; ++ ++ /** ++ * @var ResourceConnection ++ */ + private $resource; + +- /** @var DeploymentConfig */ ++ /** ++ * @var DeploymentConfig ++ */ + private $deploymentConfig; + +- /** @var string Lock prefix */ ++ /** ++ * @var string Lock prefix ++ */ + private $prefix; + +- /** @var string|false Holds current lock name if set, otherwise false */ ++ /** ++ * @var string|false Holds current lock name if set, otherwise false ++ */ + private $currentLock = false; + + /** +- * Database constructor. +- * + * @param ResourceConnection $resource + * @param DeploymentConfig $deploymentConfig + * @param string|null $prefix +@@ -53,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @return bool + * @throws InputException + * @throws AlreadyExistsException ++ * @throws \Zend_Db_Statement_Exception + */ + public function lock(string $name, int $timeout = -1): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; + $name = $this->addPrefix($name); + + /** +@@ -66,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + if ($this->currentLock) { + throw new AlreadyExistsException( + new Phrase( +- 'Current connection is already holding lock for $1, only single lock allowed', ++ 'Current connection is already holding lock for %1, only single lock allowed', + [$this->currentLock] + ) + ); +@@ -74,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + + $result = (bool)$this->resource->getConnection()->query( + "SELECT GET_LOCK(?, ?);", +- [(string)$name, (int)$timeout] ++ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] + )->fetchColumn(); + + if ($result === true) { +@@ -90,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function unlock(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return true; ++ }; ++ + $name = $this->addPrefix($name); + + $result = (bool)$this->resource->getConnection()->query( +@@ -113,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * @param string $name lock name + * @return bool + * @throws InputException ++ * @throws \Zend_Db_Statement_Exception + */ + public function isLocked(string $name): bool + { ++ if (!$this->deploymentConfig->isDbAvailable()) { ++ return false; ++ }; ++ + $name = $this->addPrefix($name); + + return (bool)$this->resource->getConnection()->query( + "SELECT IS_USED_LOCK(?);", +- [(string)$name] ++ [$name] + )->fetchColumn(); + } + +@@ -130,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * Limited to 64 characters in MySQL. + * + * @param string $name +- * @return string $name ++ * @return string + * @throws InputException + */ + private function addPrefix(string $name): string diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch similarity index 84% rename from patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch rename to patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch index 9be3c50..3319444 100644 --- a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch @@ -1,88 +1,3 @@ -diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php ---- a/vendor/magento/framework/Lock/Backend/Database.php -+++ b/vendor/magento/framework/Lock/Backend/Database.php -@@ -19,21 +19,35 @@ use Magento\Framework\Phrase; - */ - class Database implements \Magento\Framework\Lock\LockManagerInterface - { -- /** @var ResourceConnection */ -+ /** -+ * Max time for lock is 1 week -+ * -+ * MariaDB does not support negative timeout value to get infinite timeout, -+ * so we set 1 week for lock timeout -+ */ -+ const MAX_LOCK_TIME = 604800; -+ -+ /** -+ * @var ResourceConnection -+ */ - private $resource; - -- /** @var DeploymentConfig */ -+ /** -+ * @var DeploymentConfig -+ */ - private $deploymentConfig; - -- /** @var string Lock prefix */ -+ /** -+ * @var string Lock prefix -+ */ - private $prefix; - -- /** @var string|false Holds current lock name if set, otherwise false */ -+ /** -+ * @var string|false Holds current lock name if set, otherwise false -+ */ - private $currentLock = false; - - /** -- * Database constructor. -- * - * @param ResourceConnection $resource - * @param DeploymentConfig $deploymentConfig - * @param string|null $prefix -@@ -81,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - - $result = (bool)$this->resource->getConnection()->query( - "SELECT GET_LOCK(?, ?);", -- [(string)$name, (int)$timeout] -+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] - )->fetchColumn(); - - if ($result === true) { -@@ -104,6 +118,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - if (!$this->deploymentConfig->isDbAvailable()) { - return true; - }; -+ - $name = $this->addPrefix($name); - - $result = (bool)$this->resource->getConnection()->query( -@@ -131,11 +146,12 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - if (!$this->deploymentConfig->isDbAvailable()) { - return false; - }; -+ - $name = $this->addPrefix($name); - - return (bool)$this->resource->getConnection()->query( - "SELECT IS_USED_LOCK(?);", -- [(string)$name] -+ [$name] - )->fetchColumn(); - } - -@@ -145,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * Limited to 64 characters in MySQL. - * - * @param string $name -- * @return string $name -+ * @return string - * @throws InputException - */ - private function addPrefix(string $name): string diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php --- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php +++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch new file mode 100644 index 0000000..029231d --- /dev/null +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch @@ -0,0 +1,85 @@ +diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php +--- a/vendor/magento/framework/Lock/Backend/Database.php ++++ b/vendor/magento/framework/Lock/Backend/Database.php +@@ -19,21 +19,35 @@ use Magento\Framework\Phrase; + */ + class Database implements \Magento\Framework\Lock\LockManagerInterface + { +- /** @var ResourceConnection */ ++ /** ++ * Max time for lock is 1 week ++ * ++ * MariaDB does not support negative timeout value to get infinite timeout, ++ * so we set 1 week for lock timeout ++ */ ++ const MAX_LOCK_TIME = 604800; ++ ++ /** ++ * @var ResourceConnection ++ */ + private $resource; + +- /** @var DeploymentConfig */ ++ /** ++ * @var DeploymentConfig ++ */ + private $deploymentConfig; + +- /** @var string Lock prefix */ ++ /** ++ * @var string Lock prefix ++ */ + private $prefix; + +- /** @var string|false Holds current lock name if set, otherwise false */ ++ /** ++ * @var string|false Holds current lock name if set, otherwise false ++ */ + private $currentLock = false; + + /** +- * Database constructor. +- * + * @param ResourceConnection $resource + * @param DeploymentConfig $deploymentConfig + * @param string|null $prefix +@@ -81,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + + $result = (bool)$this->resource->getConnection()->query( + "SELECT GET_LOCK(?, ?);", +- [(string)$name, (int)$timeout] ++ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] + )->fetchColumn(); + + if ($result === true) { +@@ -104,6 +118,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + if (!$this->deploymentConfig->isDbAvailable()) { + return true; + }; ++ + $name = $this->addPrefix($name); + + $result = (bool)$this->resource->getConnection()->query( +@@ -131,11 +146,12 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + if (!$this->deploymentConfig->isDbAvailable()) { + return false; + }; ++ + $name = $this->addPrefix($name); + + return (bool)$this->resource->getConnection()->query( + "SELECT IS_USED_LOCK(?);", +- [(string)$name] ++ [$name] + )->fetchColumn(); + } + +@@ -145,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface + * Limited to 64 characters in MySQL. + * + * @param string $name +- * @return string $name ++ * @return string + * @throws InputException + */ + private function addPrefix(string $name): string diff --git a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch similarity index 76% rename from patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch rename to patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch index f7beda4..3319444 100644 --- a/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch +++ b/patches/MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch @@ -1,140 +1,3 @@ -diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php ---- a/vendor/magento/framework/Lock/Backend/Database.php -+++ b/vendor/magento/framework/Lock/Backend/Database.php -@@ -3,8 +3,8 @@ - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -- - declare(strict_types=1); -+ - namespace Magento\Framework\Lock\Backend; - - use Magento\Framework\App\DeploymentConfig; -@@ -14,23 +14,40 @@ use Magento\Framework\Exception\AlreadyExistsException; - use Magento\Framework\Exception\InputException; - use Magento\Framework\Phrase; - -+/** -+ * Implementation of the lock manager on the basis of MySQL. -+ */ - class Database implements \Magento\Framework\Lock\LockManagerInterface - { -- /** @var ResourceConnection */ -+ /** -+ * Max time for lock is 1 week -+ * -+ * MariaDB does not support negative timeout value to get infinite timeout, -+ * so we set 1 week for lock timeout -+ */ -+ const MAX_LOCK_TIME = 604800; -+ -+ /** -+ * @var ResourceConnection -+ */ - private $resource; - -- /** @var DeploymentConfig */ -+ /** -+ * @var DeploymentConfig -+ */ - private $deploymentConfig; - -- /** @var string Lock prefix */ -+ /** -+ * @var string Lock prefix -+ */ - private $prefix; - -- /** @var string|false Holds current lock name if set, otherwise false */ -+ /** -+ * @var string|false Holds current lock name if set, otherwise false -+ */ - private $currentLock = false; - - /** -- * Database constructor. -- * - * @param ResourceConnection $resource - * @param DeploymentConfig $deploymentConfig - * @param string|null $prefix -@@ -53,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @return bool - * @throws InputException - * @throws AlreadyExistsException -+ * @throws \Zend_Db_Statement_Exception - */ - public function lock(string $name, int $timeout = -1): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; - $name = $this->addPrefix($name); - - /** -@@ -66,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - if ($this->currentLock) { - throw new AlreadyExistsException( - new Phrase( -- 'Current connection is already holding lock for $1, only single lock allowed', -+ 'Current connection is already holding lock for %1, only single lock allowed', - [$this->currentLock] - ) - ); -@@ -74,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - - $result = (bool)$this->resource->getConnection()->query( - "SELECT GET_LOCK(?, ?);", -- [(string)$name, (int)$timeout] -+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] - )->fetchColumn(); - - if ($result === true) { -@@ -90,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function unlock(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return true; -+ }; -+ - $name = $this->addPrefix($name); - - $result = (bool)$this->resource->getConnection()->query( -@@ -113,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * @param string $name lock name - * @return bool - * @throws InputException -+ * @throws \Zend_Db_Statement_Exception - */ - public function isLocked(string $name): bool - { -+ if (!$this->deploymentConfig->isDbAvailable()) { -+ return false; -+ }; -+ - $name = $this->addPrefix($name); - - return (bool)$this->resource->getConnection()->query( - "SELECT IS_USED_LOCK(?);", -- [(string)$name] -+ [$name] - )->fetchColumn(); - } - -@@ -130,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface - * Limited to 64 characters in MySQL. - * - * @param string $name -- * @return string $name -+ * @return string - * @throws InputException - */ - private function addPrefix(string $name): string diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php --- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php +++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php diff --git a/patches/MAGETWO-53941__fix_enterprise_braintree_code__100.1.6.patch b/patches/MAGETWO-53941__fix_enterprise_braintree_code__100.1.6.patch new file mode 100644 index 0000000..a405341 --- /dev/null +++ b/patches/MAGETWO-53941__fix_enterprise_braintree_code__100.1.6.patch @@ -0,0 +1,44 @@ +diff -Nuar a/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php b/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php +--- a/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php ++++ b/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php +@@ -26,7 +26,7 @@ + /** + * @var string + */ +- private static $channelValue = 'Magento2_Cart_%s_BT'; ++ private static $channelValue = 'Magento_Enterprise_Cloud_BT'; + + /** + * Constructor +@@ -44,7 +44,7 @@ + public function build(array $buildSubject) + { + return [ +- self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition()) ++ self::$channel => self::$channelValue + ]; + } + } +diff -Nuar a/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php b/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php +--- a/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php ++++ b/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php +@@ -40,7 +40,7 @@ + public function testBuild($edition, array $expected) + { + $buildSubject = []; +- $this->productMetadataMock->expects(static::once()) ++ $this->productMetadataMock->expects(static::never()) + ->method('getEdition') + ->willReturn($edition); + +@@ -54,8 +54,8 @@ + public function buildDataProvider() + { + return [ +- ['FirstEdition', ['channel' => 'Magento2_Cart_FirstEdition_BT']], +- ['SecondEdition', ['channel' => 'Magento2_Cart_SecondEdition_BT']], ++ ['FirstEdition', ['channel' => 'Magento_Enterprise_Cloud_BT']], ++ ['SecondEdition', ['channel' => 'Magento_Enterprise_Cloud_BT']], + ]; + } + } diff --git a/patches/MAGETWO-53941__fix_enterprise_payment_codes__2.1.8.patch b/patches/MAGETWO-53941__fix_enterprise_payment_codes__2.1.8.patch deleted file mode 100644 index 1f75f0d..0000000 --- a/patches/MAGETWO-53941__fix_enterprise_payment_codes__2.1.8.patch +++ /dev/null @@ -1,93 +0,0 @@ -<+>UTF-8 -=================================================================== -diff -Nuar a/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php b/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php ---- a/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php -+++ b/vendor/magento/module-braintree/Gateway/Request/ChannelDataBuilder.php -@@ -26,7 +26,7 @@ - /** - * @var string - */ -- private static $channelValue = 'Magento2_Cart_%s_BT'; -+ private static $channelValue = 'Magento_Enterprise_Cloud_BT'; - - /** - * Constructor -@@ -44,7 +44,7 @@ - public function build(array $buildSubject) - { - return [ -- self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition()) -+ self::$channel => self::$channelValue - ]; - } - } -<+>UTF-8 -=================================================================== -diff -Nuar a/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php b/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php ---- a/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php -+++ b/vendor/magento/module-braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php -@@ -40,7 +40,7 @@ - public function testBuild($edition, array $expected) - { - $buildSubject = []; -- $this->productMetadataMock->expects(static::once()) -+ $this->productMetadataMock->expects(static::never()) - ->method('getEdition') - ->willReturn($edition); - -@@ -54,8 +54,8 @@ - public function buildDataProvider() - { - return [ -- ['FirstEdition', ['channel' => 'Magento2_Cart_FirstEdition_BT']], -- ['SecondEdition', ['channel' => 'Magento2_Cart_SecondEdition_BT']], -+ ['FirstEdition', ['channel' => 'Magento_Enterprise_Cloud_BT']], -+ ['SecondEdition', ['channel' => 'Magento_Enterprise_Cloud_BT']], - ]; - } - } -<+>UTF-8 -=================================================================== -diff -Nuar a/vendor/magento/module-paypal/Model/AbstractConfig.php b/vendor/magento/module-paypal/Model/AbstractConfig.php ---- a/vendor/magento/module-paypal/Model/AbstractConfig.php -+++ b/vendor/magento/module-paypal/Model/AbstractConfig.php -@@ -59,7 +59,7 @@ - /** - * @var string - */ -- private static $bnCode = 'Magento_Cart_%s'; -+ private static $bnCode = 'Magento_Enterprise_Cloud'; - - /** - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig -@@ -335,7 +335,7 @@ - */ - public function getBuildNotationCode() - { -- return sprintf(self::$bnCode, $this->getProductMetadata()->getEdition()); -+ return self::$bnCode; - } - - /** -<+>UTF-8 -=================================================================== -diff -Nuar a/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php b/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php ---- a/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php -+++ b/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php -@@ -293,7 +293,7 @@ - public function testGetBuildNotationCode() - { - $productMetadata = $this->getMock(ProductMetadataInterface::class, [], [], '', false); -- $productMetadata->expects($this->once()) -+ $productMetadata->expects($this->never()) - ->method('getEdition') - ->will($this->returnValue('SomeEdition')); - -@@ -304,6 +304,6 @@ - $productMetadata - ); - -- $this->assertEquals('Magento_Cart_SomeEdition', $this->config->getBuildNotationCode()); -+ $this->assertEquals('Magento_Enterprise_Cloud', $this->config->getBuildNotationCode()); - } - } diff --git a/patches/MAGETWO-53941__fix_enterprise_paypal_codes__100.1.6.patch b/patches/MAGETWO-53941__fix_enterprise_paypal_codes__100.1.6.patch new file mode 100644 index 0000000..e7f0a9c --- /dev/null +++ b/patches/MAGETWO-53941__fix_enterprise_paypal_codes__100.1.6.patch @@ -0,0 +1,41 @@ +diff -Nuar a/vendor/magento/module-paypal/Model/AbstractConfig.php b/vendor/magento/module-paypal/Model/AbstractConfig.php +--- a/vendor/magento/module-paypal/Model/AbstractConfig.php ++++ b/vendor/magento/module-paypal/Model/AbstractConfig.php +@@ -59,7 +59,7 @@ + /** + * @var string + */ +- private static $bnCode = 'Magento_Cart_%s'; ++ private static $bnCode = 'Magento_Enterprise_Cloud'; + + /** + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig +@@ -335,7 +335,7 @@ + */ + public function getBuildNotationCode() + { +- return sprintf(self::$bnCode, $this->getProductMetadata()->getEdition()); ++ return self::$bnCode; + } + + /** +diff -Nuar a/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php b/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php +--- a/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php ++++ b/vendor/magento/module-paypal/Test/Unit/Model/AbstractConfigTest.php +@@ -293,7 +293,7 @@ + public function testGetBuildNotationCode() + { + $productMetadata = $this->getMock(ProductMetadataInterface::class, [], [], '', false); +- $productMetadata->expects($this->once()) ++ $productMetadata->expects($this->never()) + ->method('getEdition') + ->will($this->returnValue('SomeEdition')); + +@@ -304,6 +304,6 @@ + $productMetadata + ); + +- $this->assertEquals('Magento_Cart_SomeEdition', $this->config->getBuildNotationCode()); ++ $this->assertEquals('Magento_Enterprise_Cloud', $this->config->getBuildNotationCode()); + } + } diff --git a/patches/MAGETWO-98129__transaction_field_is_removed_by_authorize_net__2.2.0.patch b/patches/MAGETWO-98129__transaction_field_is_removed_by_authorize_net__100.2.0.patch similarity index 100% rename from patches/MAGETWO-98129__transaction_field_is_removed_by_authorize_net__2.2.0.patch rename to patches/MAGETWO-98129__transaction_field_is_removed_by_authorize_net__100.2.0.patch diff --git a/patches/MC-31387__fix_paypal_issue_with_region__2.3.4.patch b/patches/MC-31387__fix_paypal_issue_with_region__100.3.4.patch similarity index 100% rename from patches/MC-31387__fix_paypal_issue_with_region__2.3.4.patch rename to patches/MC-31387__fix_paypal_issue_with_region__100.3.4.patch diff --git a/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.0.patch b/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.0.patch new file mode 100644 index 0000000..649cdae --- /dev/null +++ b/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.0.patch @@ -0,0 +1,155 @@ +diff -Nuar a/vendor/magento/module-sitemap/Model/Observer.php b/vendor/magento/module-sitemap/Model/Observer.php +--- a/vendor/magento/module-sitemap/Model/Observer.php ++++ b/vendor/magento/module-sitemap/Model/Observer.php +@@ -5,6 +5,9 @@ + */ + namespace Magento\Sitemap\Model; + ++use Magento\Framework\App\ObjectManager; ++use Psr\Log\LoggerInterface; ++ + /** + * Sitemap module observer + * +@@ -66,25 +69,38 @@ class Observer + */ + protected $inlineTranslation; + ++ /** ++ * @var int ++ */ ++ private $retryInterval = 10; ++ ++ /** ++ * @var LoggerInterface ++ */ ++ private $logger; ++ + /** + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder + * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ++ * @param LoggerInterface|null $logger + */ + public function __construct( + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, +- \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ++ \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, ++ LoggerInterface $logger = null + ) { + $this->_scopeConfig = $scopeConfig; + $this->_collectionFactory = $collectionFactory; + $this->_storeManager = $storeManager; + $this->_transportBuilder = $transportBuilder; + $this->inlineTranslation = $inlineTranslation; ++ $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); + } + + /** +@@ -97,6 +113,7 @@ class Observer + public function scheduledGenerateSitemaps() + { + $errors = []; ++ $sitemapsWithError = []; + + // check if scheduled generation enabled + if (!$this->_scopeConfig->isSetFlag( +@@ -114,6 +131,7 @@ class Observer + try { + $sitemap->generateXml(); + } catch (\Exception $e) { ++ $sitemapsWithError[] = $sitemap; + $errors[] = $e->getMessage(); + } + } +@@ -123,35 +141,56 @@ class Observer + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ) { +- $this->inlineTranslation->suspend(); +- +- $this->_transportBuilder->setTemplateIdentifier( +- $this->_scopeConfig->getValue( +- self::XML_PATH_ERROR_TEMPLATE, +- \Magento\Store\Model\ScopeInterface::SCOPE_STORE +- ) +- )->setTemplateOptions( +- [ +- 'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, +- 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, +- ] +- )->setTemplateVars( +- ['warnings' => join("\n", $errors)] +- )->setFrom( +- $this->_scopeConfig->getValue( +- self::XML_PATH_ERROR_IDENTITY, +- \Magento\Store\Model\ScopeInterface::SCOPE_STORE +- ) +- )->addTo( +- $this->_scopeConfig->getValue( +- self::XML_PATH_ERROR_RECIPIENT, +- \Magento\Store\Model\ScopeInterface::SCOPE_STORE +- ) +- ); +- $transport = $this->_transportBuilder->getTransport(); +- $transport->sendMessage(); +- +- $this->inlineTranslation->resume(); ++ sleep($this->retryInterval); ++ $message = 'Sitemap generation errors occurred: '; ++ $message .= join(';', $errors); ++ $this->logger->debug($message); ++ $this->logger->debug('Sitemap generation retry attempt'); ++ $nonRecoverableErrors = []; ++ //re-try to write sitemap again ++ foreach ($sitemapsWithError as $sitemap) { ++ try { ++ $sitemap->generateXml(); ++ } catch (\Exception $e) { ++ $nonRecoverableErrors[] = $e->getMessage(); ++ } ++ } ++ ++ if (!empty($nonRecoverableErrors)) { ++ $this->inlineTranslation->suspend(); ++ ++ $this->_transportBuilder->setTemplateIdentifier( ++ $this->_scopeConfig->getValue( ++ self::XML_PATH_ERROR_TEMPLATE, ++ \Magento\Store\Model\ScopeInterface::SCOPE_STORE ++ ) ++ )->setTemplateOptions( ++ [ ++ 'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, ++ 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, ++ ] ++ )->setTemplateVars( ++ ['warnings' => join("\n", $nonRecoverableErrors)] ++ )->setFrom( ++ $this->_scopeConfig->getValue( ++ self::XML_PATH_ERROR_IDENTITY, ++ \Magento\Store\Model\ScopeInterface::SCOPE_STORE ++ ) ++ )->addTo( ++ $this->_scopeConfig->getValue( ++ self::XML_PATH_ERROR_RECIPIENT, ++ \Magento\Store\Model\ScopeInterface::SCOPE_STORE ++ ) ++ ); ++ $transport = $this->_transportBuilder->getTransport(); ++ $transport->sendMessage(); ++ ++ $this->inlineTranslation->resume(); ++ ++ $message = 'Sitemap generation non-recoverable errors occurred: '; ++ $message .= join(';', $nonRecoverableErrors); ++ $this->logger->debug($message); ++ } + } + } + } diff --git a/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.3.patch b/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.3.patch new file mode 100644 index 0000000..3d58bf6 --- /dev/null +++ b/patches/MCLOUD-3025__sitemap_generation_warnings__2.3.3.patch @@ -0,0 +1,92 @@ +diff -Nuar a/vendor/magento/module-sitemap/Model/Observer.php b/vendor/magento/module-sitemap/Model/Observer.php +--- a/vendor/magento/module-sitemap/Model/Observer.php ++++ b/vendor/magento/module-sitemap/Model/Observer.php +@@ -7,8 +7,10 @@ namespace Magento\Sitemap\Model; + + use Magento\Sitemap\Model\EmailNotification as SitemapEmail; + use Magento\Framework\App\Config\ScopeConfigInterface; ++use Magento\Framework\App\ObjectManager; + use Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory; + use Magento\Store\Model\ScopeInterface; ++use Psr\Log\LoggerInterface; + + /** + * Sitemap module observer +@@ -61,20 +63,33 @@ class Observer + */ + private $emailNotification; + ++ /** ++ * @var int ++ */ ++ private $retryInterval = 10; ++ ++ /** ++ * @var LoggerInterface ++ */ ++ private $logger; ++ + /** + * Observer constructor. + * @param ScopeConfigInterface $scopeConfig + * @param CollectionFactory $collectionFactory + * @param EmailNotification $emailNotification ++ * @param LoggerInterface|null $logger + */ + public function __construct( + ScopeConfigInterface $scopeConfig, + CollectionFactory $collectionFactory, +- SitemapEmail $emailNotification ++ SitemapEmail $emailNotification, ++ LoggerInterface $logger = null + ) { + $this->scopeConfig = $scopeConfig; + $this->collectionFactory = $collectionFactory; + $this->emailNotification = $emailNotification; ++ $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); + } + + /** +@@ -87,6 +102,7 @@ class Observer + public function scheduledGenerateSitemaps() + { + $errors = []; ++ $sitemapsWithError = []; + $recipient = $this->scopeConfig->getValue( + Observer::XML_PATH_ERROR_RECIPIENT, + ScopeInterface::SCOPE_STORE +@@ -107,11 +123,33 @@ class Observer + try { + $sitemap->generateXml(); + } catch (\Exception $e) { ++ $sitemapsWithError[] = $sitemap; + $errors[] = $e->getMessage(); + } + } ++ + if ($errors && $recipient) { +- $this->emailNotification->sendErrors($errors); ++ sleep($this->retryInterval); ++ $message = 'Sitemap generation errors occurred: '; ++ $message .= join(';', $errors); ++ $this->logger->debug($message); ++ $this->logger->debug('Sitemap generation retry attempt'); ++ $nonRecoverableErrors = []; ++ //re-try to write sitemap again ++ foreach ($sitemapsWithError as $sitemap) { ++ try { ++ $sitemap->generateXml(); ++ } catch (\Exception $e) { ++ $nonRecoverableErrors[] = $e->getMessage(); ++ } ++ } ++ if (!empty($nonRecoverableErrors)) { ++ $this->emailNotification->sendErrors($nonRecoverableErrors); ++ $message = 'Sitemap generation non-recoverable errors occurred: '; ++ $message .= join(';', $nonRecoverableErrors); ++ $this->logger->debug($message); ++ } + } ++ + } + } diff --git a/patches/MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch b/patches/MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch new file mode 100644 index 0000000..fe03cf1 --- /dev/null +++ b/patches/MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch @@ -0,0 +1,102 @@ +diff -Nuar a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php +--- a/vendor/magento/framework/App/DeploymentConfig.php ++++ b/vendor/magento/framework/App/DeploymentConfig.php +@@ -86,7 +86,6 @@ public function get($key = null, $defaultValue = null) + */ + public function isAvailable() + { +- $this->data = null; + $this->load(); + return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]); + } +@@ -141,7 +140,7 @@ public function isDbAvailable() + */ + private function load() + { +- if (null === $this->data) { ++ if (empty($this->data)) { + $this->data = $this->reader->load(); + if ($this->overrideData) { + $this->data = array_replace($this->data, $this->overrideData); +@@ -173,10 +172,12 @@ private function flattenParams(array $params, $path = null) + $newPath = $key; + } + if (isset($cache[$newPath])) { ++ //phpcs:ignore Magento2.Exceptions.DirectThrow + throw new \Exception("Key collision {$newPath} is already defined."); + } + $cache[$newPath] = $param; + if (is_array($param)) { ++ //phpcs:ignore Magento2.Performance.ForeachArrayMerge + $cache = array_merge($cache, $this->flattenParams($param, $newPath)); + } + } +diff -Nuar a/vendor/magento/framework/Locale/Resolver.php b/vendor/magento/framework/Locale/Resolver.php +--- a/vendor/magento/framework/Locale/Resolver.php ++++ b/vendor/magento/framework/Locale/Resolver.php +@@ -15,7 +15,7 @@ + class Resolver implements ResolverInterface + { + /** +- * Default locale ++ * Resolver default locale + */ + const DEFAULT_LOCALE = 'en_US'; + +@@ -79,7 +79,7 @@ public function __construct( + $this->scopeConfig = $scopeConfig; + $this->defaultLocalePath = $defaultLocalePath; + $this->scopeType = $scopeType; +- $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class); ++ $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class); + $this->setLocale($locale); + } + +diff -Nuar a/vendor/magento/framework/Module/ModuleList.php b/vendor/magento/framework/Module/ModuleList.php +--- a/vendor/magento/framework/Module/ModuleList.php ++++ b/vendor/magento/framework/Module/ModuleList.php +@@ -59,7 +59,7 @@ public function __construct(DeploymentConfig $config, ModuleList\Loader $loader) + } + + /** +- * {@inheritdoc} ++ * @inheritdoc + * + * Note that this triggers loading definitions of all existing modules in the system. + * Use this method only when you actually need modules' declared meta-information. +@@ -84,7 +84,8 @@ public function getAll() + } + + /** +- * {@inheritdoc} ++ * @inheritdoc ++ * + * @see has() + */ + public function getOne($name) +@@ -94,7 +95,7 @@ public function getOne($name) + } + + /** +- * {@inheritdoc} ++ * @inheritdoc + */ + public function getNames() + { +@@ -107,7 +108,7 @@ public function getNames() + } + + /** +- * {@inheritdoc} ++ * @inheritdoc + */ + public function has($name) + { +@@ -139,7 +140,6 @@ public function isModuleInfoAvailable() + */ + private function loadConfigData() + { +- $this->config->resetData(); + if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) { + $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); + } diff --git a/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.2.patch b/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.2.patch new file mode 100644 index 0000000..ef3d3a2 --- /dev/null +++ b/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.2.patch @@ -0,0 +1,18 @@ +diff -Nuar a/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php b/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php +--- a/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php ++++ b/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php +@@ -76,11 +76,13 @@ + */ + public function resolve(): SearchCriteria + { +- $this->builder->setPageSize($this->size); + $searchCriteria = $this->builder->create(); + $searchCriteria->setRequestName($this->searchRequestName); + $searchCriteria->setSortOrders($this->orders); + $searchCriteria->setCurrentPage($this->currentPage - 1); ++ if ($this->size) { ++ $searchCriteria->setPageSize($this->size); ++ } + + return $searchCriteria; + } diff --git a/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.4.patch b/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.4.patch new file mode 100644 index 0000000..c80ad18 --- /dev/null +++ b/patches/MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.4.patch @@ -0,0 +1,13 @@ +diff -Nuar a/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php b/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php +--- a/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php ++++ b/vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php +@@ -80,6 +80,9 @@ + $searchCriteria->setRequestName($this->searchRequestName); + $searchCriteria->setSortOrders($this->orders); + $searchCriteria->setCurrentPage($this->currentPage - 1); ++ if ($this->size) { ++ $searchCriteria->setPageSize($this->size); ++ } + + return $searchCriteria; + } diff --git a/src/Test/Functional/Acceptance.suite.dist.yml b/src/Test/Functional/Acceptance.suite.dist.yml new file mode 100644 index 0000000..cf28434 --- /dev/null +++ b/src/Test/Functional/Acceptance.suite.dist.yml @@ -0,0 +1,7 @@ +actor: CliTester +modules: + enabled: + - Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure + - Magento\CloudDocker\Test\Functional\Codeception\Docker + - PhpBrowser + - Asserts diff --git a/src/Test/Functional/Acceptance/Acceptance71CeCest.php b/src/Test/Functional/Acceptance/Acceptance71CeCest.php new file mode 100644 index 0000000..26f2d77 --- /dev/null +++ b/src/Test/Functional/Acceptance/Acceptance71CeCest.php @@ -0,0 +1,19 @@ + '2.1.16'], + ['templateVersion' => '2.1.17'], + ['templateVersion' => '2.1.18'], + ['templateVersion' => '2.2.0'], + ['templateVersion' => '2.2.1'], + ['templateVersion' => '2.2.2'], + ['templateVersion' => '2.2.3'], + ['templateVersion' => '2.2.4'], + ['templateVersion' => '2.2.5'], + ['templateVersion' => '2.2.6'], + ['templateVersion' => '2.2.7'], + ['templateVersion' => '2.2.8'], + ['templateVersion' => '2.2.9'], + ['templateVersion' => '2.2.10'], + ['templateVersion' => '2.2.11'], + ]; + } +} diff --git a/src/Test/Functional/Acceptance/Acceptance72CeCest.php b/src/Test/Functional/Acceptance/Acceptance72CeCest.php new file mode 100644 index 0000000..8024546 --- /dev/null +++ b/src/Test/Functional/Acceptance/Acceptance72CeCest.php @@ -0,0 +1,19 @@ + '2.3.0'], + ['templateVersion' => '2.3.1'], + ['templateVersion' => '2.3.2'], + ]; + } +} diff --git a/src/Test/Functional/Acceptance/AcceptanceCeCest.php b/src/Test/Functional/Acceptance/AcceptanceCeCest.php new file mode 100644 index 0000000..cdf0e2d --- /dev/null +++ b/src/Test/Functional/Acceptance/AcceptanceCeCest.php @@ -0,0 +1,19 @@ +cleanupWorkDir(); + } + + /** + * @param \CliTester $I + * @param string $templateVersion + */ + protected function prepareTemplate(\CliTester $I, string $templateVersion): void + { + $I->cloneTemplateToWorkDir($templateVersion); + $I->createAuthJson(); + $I->createArtifactsDir(); + $I->createArtifactCurrentTestedCode('patches', '1.0.99'); + $I->addArtifactsRepoToComposer(); + $I->addEceDockerGitRepoToComposer(); + $I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99'); + $I->addDependencyToComposer( + 'magento/magento-cloud-docker', + $I->getDependencyVersion('magento/magento-cloud-docker') + ); + + if ($this->edition === 'CE') { + $version = $this->getVersionRangeForMagento($I); + $I->removeDependencyFromComposer('magento/magento-cloud-metapackage'); + $I->addDependencyToComposer('magento/ece-tools', '^2002.1.0'); + $I->addDependencyToComposer('magento/product-community-edition', $version); + } + + $I->composerUpdate(); + } + + /** + * @param \CliTester $I + * @return string + */ + protected function getVersionRangeForMagento(\CliTester $I): string + { + $composer = json_decode(file_get_contents($I->getWorkDirPath() . '/composer.json'), true); + + return $composer['require']['magento/magento-cloud-metapackage'] ?? ''; + } + + /** + * @param \CliTester $I + * @param \Codeception\Example $data + * @throws \Robo\Exception\TaskException + * @dataProvider patchesDataProvider + */ + public function testPatches(\CliTester $I, \Codeception\Example $data): void + { + $this->prepareTemplate($I, $data['templateVersion']); + $I->assertTrue($I->runEceDockerCommand('build:compose --mode=production')); + $I->assertTrue($I->runDockerComposeCommand('run build cloud-build')); + $I->assertTrue($I->startEnvironment()); + $I->assertTrue($I->runDockerComposeCommand('run deploy cloud-deploy')); + $I->assertTrue($I->runDockerComposeCommand('run deploy cloud-post-deploy')); + $I->amOnPage('/'); + $I->see('Home page'); + $I->see('CMS homepage content goes here.'); + } + + /** + * @return array + */ + protected function patchesDataProvider(): array + { + return [ + ['templateVersion' => '2.3.3'], + ['templateVersion' => '2.3.4'], + ['templateVersion' => 'master'], + ]; + } + + /** + * @param \CliTester $I + */ + public function _after(\CliTester $I): void + { + $I->stopEnvironment(); + $I->removeWorkDir(); + } +} diff --git a/tests/functional/_data/.gitkeep b/tests/functional/_data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/_data/files/debug_logging/.magento.env.yaml b/tests/functional/_data/files/debug_logging/.magento.env.yaml new file mode 100644 index 0000000..f9b165b --- /dev/null +++ b/tests/functional/_data/files/debug_logging/.magento.env.yaml @@ -0,0 +1,9 @@ +stage: + global: + MIN_LOGGING_LEVEL: debug + +log: + file: + min_level: "debug" + stream: + min_level: "debug" diff --git a/tests/functional/_output/.gitignore b/tests/functional/_output/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/functional/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/travis/functional-ce.sh b/tests/travis/functional-ce.sh new file mode 100755 index 0000000..6eedc70 --- /dev/null +++ b/tests/travis/functional-ce.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +set -e +trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR + +case $TRAVIS_PHP_VERSION in + 7.1) + ./vendor/bin/codecept run -g php71ce --steps + ;; + 7.2) + ./vendor/bin/codecept run -g php72ce --steps + ;; + 7.3) + ./vendor/bin/codecept run -g php73ce --steps + ;; +esac diff --git a/tests/travis/functional-ee.sh b/tests/travis/functional-ee.sh new file mode 100755 index 0000000..a0d12a1 --- /dev/null +++ b/tests/travis/functional-ee.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +set -e +trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR + +case $TRAVIS_PHP_VERSION in + 7.1) + ./vendor/bin/codecept run -g php71 --steps + ;; + 7.2) + ./vendor/bin/codecept run -g php72 --steps + ;; + 7.3) + ./vendor/bin/codecept run -g php73 --steps + ;; +esac diff --git a/tests/travis/static-unit.sh b/tests/travis/static-unit.sh new file mode 100755 index 0000000..dc99e6a --- /dev/null +++ b/tests/travis/static-unit.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +set -e +trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR + +./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n +./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml +./vendor/bin/phpunit --configuration ./tests/unit