Skip to content

Commit db5ca6e

Browse files
authored
MCLOUD-6423: MC-34580: Magento Quality Patches (magento#55)
1 parent ab30c6e commit db5ca6e

File tree

116 files changed

+10064
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+10064
-681
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ install:
5959
- composer config http-basic.repo.magento.com ${REPO_USERNAME_CE} ${REPO_PASSWORD_CE}
6060
- composer config github-oauth.github.com ${GITHUB_TOKEN}
6161
- if [ -n "${MCD_VERSION}" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then composer config repositories.mcd git [email protected]:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi;
62+
- if [ -n "${MQP_VERSION}" ]; then composer config repositories.mqp git [email protected]:magento/quality-patches.git && composer require "magento/quality-patches:${MQP_VERSION}" --no-update; fi;
6263
- composer update -n --no-suggest
6364

6465
before_script:

bin/magento-patches

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
$container = require __DIR__ . '/../bootstrap.php';
8+
9+
$application = new Magento\CloudPatches\Application($container);
10+
$application->run();

codeception.dist.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ modules:
2020
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
2121
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
2222
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
23+
mqp_repo: "https://github.com/magento/quality-patches.git"
2324
composer_magento_username: "%REPO_USERNAME%"
2425
composer_magento_password: "%REPO_PASSWORD%"
2526
composer_github_token: "%GITHUB_TOKEN%"

composer.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"symfony/config": "^3.3||^4.4",
1313
"symfony/console": "^2.6||^4.0",
1414
"symfony/dependency-injection": "^3.3||^4.3",
15-
"symfony/process": "^2.1||^4.1"
15+
"symfony/process": "^2.1||^4.1",
16+
"symfony/proxy-manager-bridge": "^3.3||^4.3",
17+
"monolog/monolog": "^1.16",
18+
"magento/quality-patches": "^1.0.0"
1619
},
1720
"require-dev": {
1821
"codeception/codeception": "^2.5.3",
@@ -22,7 +25,8 @@
2225
"squizlabs/php_codesniffer": "^3.0"
2326
},
2427
"bin": [
25-
"bin/ece-patches"
28+
"bin/ece-patches",
29+
"bin/magento-patches"
2630
],
2731
"autoload": {
2832
"psr-4": {

config/services.xml

+64-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,75 @@
66

77
<prototype namespace="Magento\CloudPatches\" resource="../src/*" exclude="../src/{Test}"/>
88

9+
<service id="Psr\Log\LoggerInterface" alias="Magento\CloudPatches\App\Logger" />
910
<service id="Magento\CloudPatches\App\Container" autowire="false"/>
1011
<service id="Magento\CloudPatches\Filesystem\DirectoryList" autowire="false"/>
12+
<service id="Magento\QualityPatches\Info"/>
13+
<service id="Symfony\Component\Console\Helper\QuestionHelper"/>
1114
<service id="Composer\Composer"/>
1215
<service id="Magento\CloudPatches\App\GenericException" autowire="false"/>
13-
<service id="Magento\CloudPatches\Command\Patch\ManagerException" autowire="false"/>
16+
<service id="Magento\CloudPatches\App\RuntimeException" autowire="false"/>
17+
<service id="Magento\CloudPatches\Filesystem\FileSystemException" autowire="false"/>
18+
<service id="Magento\CloudPatches\Patch\SourceProviderException" autowire="false"/>
19+
<service id="Magento\CloudPatches\Patch\Collector\CollectorException" autowire="false"/>
20+
<service id="Magento\CloudPatches\Patch\Status\StatusResolverException" autowire="false"/>
21+
<service id="Magento\CloudPatches\Patch\PatchIntegrityException" autowire="false"/>
22+
<service id="Magento\CloudPatches\Patch\Pool\PatchNotFoundException" autowire="false"/>
1423
<service id="Magento\CloudPatches\Patch\ApplierException" autowire="false"/>
15-
<service id="Magento\CloudPatches\Filesystem\FileNotFoundException" autowire="false"/>
1624
<service id="Magento\CloudPatches\Shell\PackageNotFoundException" autowire="false"/>
25+
<service id="Magento\CloudPatches\Patch\Data\Patch" autowire="false"/>
26+
<service id="Magento\CloudPatches\Patch\Data\AggregatedPatch" autowire="false"/>
27+
<service id="Magento\CloudPatches\Patch\Pool\OptionalPool" lazy="true" />
28+
<service id="Magento\CloudPatches\Patch\Pool\RequiredPool" lazy="true"/>
29+
<service id="Magento\CloudPatches\Patch\Pool\LocalPool" lazy="true"/>
30+
<service id="Magento\CloudPatches\Patch\Status\StatusPool" autowire="false"/>
31+
<service id="statusOptionalPool" class="Magento\CloudPatches\Patch\Status\StatusPool" lazy="true">
32+
<argument key="$resolvers" type="collection">
33+
<argument type="service" id="Magento\CloudPatches\Patch\Status\OptionalResolver"/>
34+
</argument>
35+
</service>
36+
<service id="statusPool" class="Magento\CloudPatches\Patch\Status\StatusPool" lazy="true">
37+
<argument key="$resolvers" type="collection">
38+
<argument type="service" id="Magento\CloudPatches\Patch\Status\LocalResolver"/>
39+
<argument type="service" id="Magento\CloudPatches\Patch\Status\OptionalResolver"/>
40+
</argument>
41+
</service>
42+
<service id="Magento\CloudPatches\Command\Process\ShowStatus">
43+
<argument key="$statusPool" type="service" id="statusPool"/>
44+
</service>
45+
<service id="Magento\CloudPatches\Command\Process\Action\ApplyOptionalAction">
46+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
47+
</service>
48+
<service id="Magento\CloudPatches\Command\Process\Action\RevertAction">
49+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
50+
</service>
51+
<service id="Magento\CloudPatches\Command\Process\Action\ConfirmRequiredAction">
52+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
53+
</service>
54+
<service id="Magento\CloudPatches\Command\Process\Action\ProcessDeprecatedAction">
55+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
56+
</service>
57+
<service id="Magento\CloudPatches\Command\Process\Action\ReviewAppliedAction">
58+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
59+
</service>
60+
<service id="Magento\CloudPatches\Patch\RevertValidator">
61+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
62+
</service>
63+
<service id="Magento\CloudPatches\Command\Process\Renderer">
64+
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
65+
</service>
66+
<service id="Magento\CloudPatches\Command\Process\Action\ActionPool" autowire="false"/>
67+
<service id="ApplyOptionalActionPool" class="Magento\CloudPatches\Command\Process\Action\ActionPool">
68+
<argument key="$actions" type="collection">
69+
<argument type="service" id="Magento\CloudPatches\Command\Process\Action\ReviewAppliedAction"/>
70+
<argument type="service" id="Magento\CloudPatches\Command\Process\Action\ConfirmRequiredAction"/>
71+
<argument type="service" id="Magento\CloudPatches\Command\Process\Action\ProcessDeprecatedAction"/>
72+
<argument type="service" id="Magento\CloudPatches\Command\Process\Action\ApplyOptionalAction"/>
73+
</argument>
74+
</service>
75+
<service id="Magento\CloudPatches\Command\Process\ApplyOptional">
76+
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
77+
</service>
78+
<service id="Magento\CloudPatches\Patch\PatchBuilder" shared="false"/>
1779
</services>
1880
</container>

patches.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
">=2.3.1 <2.3.3": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.1.patch"
117117
},
118118
"Resolve Issues with Cron Schedule": {
119-
"2.1.10 - 2.1.14 || 2.2.2 - 2.2.5": "MAGECLOUD-2427__resolve_issues_with_cron_schedule.patch"
119+
"2.1.10 - 2.1.14 || 2.2.2 - 2.2.5": "MAGECLOUD-2427__resolve_issues_with_cron_schedule__2.1.10.patch"
120120
},
121121
"Fix timezone parsing for Cron": {
122122
"2.1.4": "MAGECLOUD-2602__fix_timezone_parsing_for_cron__2.1.4.patch",
@@ -135,7 +135,7 @@
135135
"2.1.4 - 2.2.5": "MAGECLOUD-2445__do_not_run_cron_when_it_is_disabled__2.1.4.patch"
136136
},
137137
"Zendframework1 should use TLS 1.2": {
138-
">=2.1.4 <2.3": "MAGECLOUD-2521__zendframework1_use_TLS_1.2.patch"
138+
">=2.1.4 <2.3": "MAGECLOUD-2521__zendframework1_use_TLS_1.2__2.1.4.patch"
139139
},
140140
"The recursion detected error during deployment": {
141141
"2.2.0 - 2.2.6": "MAGECLOUD-2173__the_recursion_error_during_deployment__2.2.0.patch"
@@ -145,15 +145,15 @@
145145
"2.2.6": "MAGECLOUD-2509__remove_permission_check_for_console_application__2.2.6.patch"
146146
},
147147
"Fix for DI compilation with Amazon_Payment module": {
148-
"2.2.6": "MAGECLOUD-2850_fix_amazon_payment_module__2.2.6.patch"
148+
"2.2.6": "MAGECLOUD-2850__fix_amazon_payment_module__2.2.6.patch"
149149
},
150150
"Add the possibility to install Magento without admin creation" : {
151151
"2.1.4 - 2.2.1": "MAGECLOUD-2573__installation_without_admin_creation__2.1.4.patch",
152152
"2.2.2 - 2.2.7": "MAGECLOUD-2573__installation_without_admin_creation__2.2.2.patch"
153153
},
154154
"Add the possibility to configure max execution time during static content deployment": {
155-
"2.2.0 - 2.2.8 || 2.3.0": "MAGECLOUD-2822__configure_max_execution_time.patch",
156-
"2.3.1": "MAGECLOUD-2822__configure_max_execution_time_2.3.1.patch"
155+
"2.2.0 - 2.2.8 || 2.3.0": "MAGECLOUD-2822__configure_max_execution_time__2.2.0.patch",
156+
"2.3.1": "MAGECLOUD-2822__configure_max_execution_time__2.3.1.patch"
157157
},
158158
"Suppress PDO warnings to work around PHP bugs #63812, #74401": {
159159
"2.1.4": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.1.4.patch",
@@ -232,7 +232,7 @@
232232
">=2.3.5 <2.4.0": "MAGECLOUD-5069__fpc_is_getting_disabled_during_deployments__2.3.5.patch"
233233
},
234234
"Hold deployment config after reading from file": {
235-
">=2.3.3 <2.3.6": "MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch"
235+
">=2.3.3 <2.3.6": "MCLOUD-5650__hold_deployment_config_after_reading_from_file__2.3.3.patch"
236236
},
237237
"Pagination Not working - product_list_limit=all": {
238238
">=2.3.2 <2.3.4": "MCLOUD-5684__pagination_not_working_product_list_limit_all__2.3.2.patch",
@@ -274,8 +274,8 @@
274274
},
275275
"monolog/monolog": {
276276
"Fix monolog Slack Handler bug for magento 2.1.x": {
277-
"1.16.0": "MAGECLOUD-2793__fix_monolog_slack_handler_2.1.x.patch",
278-
">=1.16.0 <1.24.0": "MAGECLOUD-6029__add_processor_interface_2.1.x.patch"
277+
"1.16.0": "MAGECLOUD-2793__fix_monolog_slack_handler__2.1.x.patch",
278+
">=1.16.0 <1.24.0": "MAGECLOUD-6029__add_processor_interface__2.1.x.patch"
279279
}
280280
},
281281
"colinmollenhour/cache-backend-redis": {

src/App/Container.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Composer;
1111
use Magento\CloudPatches\Filesystem\DirectoryList;
1212
use Psr\Container\ContainerInterface;
13+
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
1314
use Symfony\Component\Config\FileLocator;
1415
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Definition;
@@ -37,6 +38,8 @@ class Container implements ContainerInterface
3738
public function __construct(string $basePath, string $magentoBasePath)
3839
{
3940
$containerBuilder = new ContainerBuilder();
41+
$containerBuilder->setProxyInstantiator(new RuntimeInstantiator());
42+
4043
$containerBuilder->set('container', $containerBuilder);
4144
$containerBuilder->setDefinition('container', new Definition(__CLASS__))
4245
->setArguments([$basePath, $magentoBasePath]);
@@ -72,7 +75,9 @@ private function createComposerInstance(DirectoryList $directoryList): Composer\
7275
new Composer\IO\BufferIO(),
7376
$composerFile,
7477
false,
75-
$directoryList->getMagentoRoot()
78+
is_dir($directoryList->getMagentoRoot())
79+
? $directoryList->getMagentoRoot()
80+
: $directoryList->getRoot()
7681
);
7782

7883
return $composer;

src/App/Logger.php

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\App;
9+
10+
use Magento\CloudPatches\App\Logger\LineFormatterFactory;
11+
use Magento\CloudPatches\Filesystem\FileList;
12+
use Magento\CloudPatches\Filesystem\Filesystem;
13+
use Monolog\Handler\NullHandler;
14+
use Monolog\Handler\StreamHandler;
15+
16+
/**
17+
* @inheritdoc
18+
*/
19+
class Logger extends \Monolog\Logger
20+
{
21+
/**
22+
* @param FileList $fileList
23+
* @param Logger\LineFormatterFactory $lineFormatterFactory
24+
* @param Filesystem $filesystem
25+
*/
26+
public function __construct(
27+
FileList $fileList,
28+
LineFormatterFactory $lineFormatterFactory,
29+
Filesystem $filesystem
30+
) {
31+
$handlers = [];
32+
$logPath = $fileList->getPatchLog();
33+
$logDir = $filesystem->getDirectory($logPath);
34+
$filesystem->createDirectory($logDir);
35+
36+
if ($filesystem->isWritable($logDir)) {
37+
try {
38+
$handlerInstance = new StreamHandler($logPath, Logger::DEBUG);
39+
$formatter = $lineFormatterFactory->create();
40+
$handlerInstance->setFormatter($formatter);
41+
$handlers[] = $handlerInstance;
42+
} catch (\Exception $e) {
43+
$handlers[] = new NullHandler();
44+
}
45+
} else {
46+
$handlers[] = new NullHandler();
47+
}
48+
49+
parent::__construct('default', $handlers);
50+
}
51+
52+
/**
53+
* @inheritDoc
54+
*/
55+
public function info($message, array $context = [])
56+
{
57+
$message = strip_tags($message);
58+
59+
parent::info($message, $context);
60+
}
61+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\App\Logger;
9+
10+
use Monolog\Formatter\LineFormatter;
11+
12+
/**
13+
* The factory for LineFormatter.
14+
*/
15+
class LineFormatterFactory
16+
{
17+
/**
18+
* @return LineFormatter
19+
*/
20+
public function create(): LineFormatter
21+
{
22+
return new LineFormatter("[%datetime%] %level_name%: %message% %context% %extra%\n", null, true, true);
23+
}
24+
}

src/App/RuntimeException.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\App;
9+
10+
/**
11+
* Exception thrown if an error which can only be found on runtime occurs.
12+
*/
13+
class RuntimeException extends GenericException
14+
{
15+
}

src/Application.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ protected function getDefaultCommands()
4141
{
4242
return array_merge(parent::getDefaultCommands(), [
4343
$this->container->get(Command\Apply::class),
44+
$this->container->get(Command\Revert::class),
45+
$this->container->get(Command\Status::class)
4446
]);
4547
}
4648
}

src/Command/AbstractCommand.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\Command;
9+
10+
use Symfony\Component\Console\Command\Command;
11+
12+
/**
13+
* @inheritDoc
14+
*/
15+
class AbstractCommand extends Command
16+
{
17+
/**
18+
* Cli exit code - success.
19+
*/
20+
const RETURN_SUCCESS = 0;
21+
22+
/**
23+
* Cli exit code - failure.
24+
*/
25+
const RETURN_FAILURE = 1;
26+
}

0 commit comments

Comments
 (0)