Skip to content

Commit 39d1968

Browse files
authored
Merge pull request #65 from magento-commerce/develop
MCLOUD-9560: October cloud tools release
2 parents 38a601e + 138c65e commit 39d1968

17 files changed

+156
-185
lines changed

.travis.yml

-96
This file was deleted.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento-cloud-patches",
33
"description": "Provides critical fixes for Magento 2 Enterprise Edition",
44
"type": "magento2-component",
5-
"version": "1.0.19",
5+
"version": "1.0.20",
66
"license": "OSL-3.0",
77
"repositories": {
88
"repo.magento.com": {

patches.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@
255255
">=2.3.3-p1 <2.3.4": "MCLOUD-6139_MCLOUD-6211__redis_improvement_patches__2.3.3-p1.patch",
256256
">=2.3.4 <2.3.5": "MCLOUD-6139_MCLOUD-6211__redis_improvement_patches__2.3.4.patch",
257257
">=2.3.5 <2.3.6": "MCLOUD-6211__redis_improvement_patches__2.3.5.patch",
258-
">=2.4.0 <2.4.1": "MCLOUD-6659__fix_L2_redis_cache__2.4.0.patch"
258+
">=2.4.0 <2.4.1": "MCLOUD-6659__fix_L2_redis_cache__2.4.0.patch",
259+
">=2.4.1 <2.4.2": "MCLOUD-7845__fix_local_flushing_L2_cache__2.4.0.patch"
259260
},
260261
"Incompatible PHP Method Fix": {
261262
"2.3.7-p1": "AC-384__Fix_Incompatible_PHP_Method__2.3.7-p1_ce.patch",
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
22
--- a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
33
+++ b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
4-
@@ -205,7 +205,7 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
4+
@@ -237,7 +237,7 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
55
$dataToSave = $data;
66
$remHash = $this->loadRemoteDataVersion($id);
77

@@ -10,3 +10,37 @@ diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
1010
$dataToSave = $this->remote->load($id);
1111
} else {
1212
$this->remote->save($data, $id, $tags, $specificLifetime);
13+
@@ -248,9 +248,23 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
14+
$this->unlock($id);
15+
}
16+
17+
+ if (!mt_rand(0, 100) && $this->checkIfLocalCacheSpaceExceeded()) {
18+
+ $this->local->clean();
19+
+ }
20+
+
21+
return $this->local->save($dataToSave, $id, [], $specificLifetime);
22+
}
23+
24+
+ /**
25+
+ * Check if local cache space bigger that configure amount
26+
+ *
27+
+ * @return bool
28+
+ */
29+
+ private function checkIfLocalCacheSpaceExceeded()
30+
+ {
31+
+ return $this->getFillingPercentage() >= 95;
32+
+ }
33+
+
34+
/**
35+
* @inheritdoc
36+
*/
37+
@@ -266,7 +280,8 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
38+
*/
39+
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
40+
{
41+
- return $this->remote->clean($mode, $tags);
42+
+ return $this->remote->clean($mode, $tags) &&
43+
+ $this->local->clean($mode, $tags);
44+
}
45+
46+
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
2+
index d0c05613..96f7ad84 100644
3+
--- a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
4+
+++ b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
5+
@@ -248,9 +248,23 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
6+
$this->unlock($id);
7+
}
8+
9+
+ if (!mt_rand(0, 100) && $this->checkIfLocalCacheSpaceExceeded()) {
10+
+ $this->local->clean();
11+
+ }
12+
+
13+
return $this->local->save($dataToSave, $id, [], $specificLifetime);
14+
}
15+
16+
+ /**
17+
+ * Check if local cache space bigger that configure amount
18+
+ *
19+
+ * @return bool
20+
+ */
21+
+ private function checkIfLocalCacheSpaceExceeded()
22+
+ {
23+
+ return $this->getFillingPercentage() >= 95;
24+
+ }
25+
+
26+
/**
27+
* @inheritdoc
28+
*/
29+
@@ -266,7 +280,8 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
30+
*/
31+
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
32+
{
33+
- return $this->remote->clean($mode, $tags);
34+
+ return $this->remote->clean($mode, $tags) &&
35+
+ $this->local->clean($mode, $tags);
36+
}
37+
38+
/**

src/Command/Process/Renderer.php

+35
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ public function printTable(OutputInterface $output, array $patchList)
105105
$table->render();
106106
}
107107

108+
/**
109+
* Renders patches list as JSON.
110+
*
111+
* @param OutputInterface $output
112+
* @param AggregatedPatchInterface[] $patchList
113+
* @return void
114+
*/
115+
public function printJson(OutputInterface $output, array $patchList)
116+
{
117+
$rows = [];
118+
foreach ($patchList as $patch) {
119+
$rows[] = $this->createJsonRow($patch);
120+
}
121+
122+
usort($rows, function ($a, $b) {
123+
if ($a[self::STATUS] === $b[self::STATUS]) {
124+
return strcmp($a[self::ORIGIN], $b[self::ORIGIN]);
125+
}
126+
return strcmp($a[self::STATUS], $b[self::STATUS]);
127+
});
128+
129+
$output->writeln(json_encode($rows, JSON_PRETTY_PRINT));
130+
}
131+
108132
/**
109133
* Print patch info.
110134
*
@@ -209,6 +233,17 @@ function ($item) {
209233
];
210234
}
211235

236+
/**
237+
* Creates JSON row.
238+
*
239+
* @param AggregatedPatchInterface $patch
240+
* @return array
241+
*/
242+
private function createJsonRow(AggregatedPatchInterface $patch): array
243+
{
244+
return array_map('strip_tags', $this->createRow($patch));
245+
}
246+
212247
/**
213248
* Adds table separator.
214249
*

src/Command/Process/ShowStatus.php

+28-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CloudPatches\Command\Process;
99

1010
use Magento\CloudPatches\Command\Process\Action\ReviewAppliedAction;
11+
use Magento\CloudPatches\Composer\MagentoVersion;
1112
use Magento\CloudPatches\Console\QuestionFactory;
1213
use Magento\CloudPatches\Patch\Data\AggregatedPatch;
1314
use Magento\CloudPatches\Patch\Data\AggregatedPatchInterface;
@@ -28,6 +29,8 @@ class ShowStatus implements ProcessInterface
2829

2930
const FILTER_OPTION_ALL = 'All';
3031

32+
const FORMAT_JSON = 'json';
33+
3134
/**
3235
* @var Aggregator
3336
*/
@@ -43,6 +46,11 @@ class ShowStatus implements ProcessInterface
4346
*/
4447
private $localPool;
4548

49+
/**
50+
* @var MagentoVersion
51+
*/
52+
private $magentoVersion;
53+
4654
/**
4755
* @var StatusPool
4856
*/
@@ -86,7 +94,8 @@ public function __construct(
8694
ReviewAppliedAction $reviewAppliedAction,
8795
Renderer $renderer,
8896
QuestionHelper $questionHelper,
89-
QuestionFactory $questionFactory
97+
QuestionFactory $questionFactory,
98+
MagentoVersion $magentoVersion
9099
) {
91100
$this->aggregator = $aggregator;
92101
$this->optionalPool = $optionalPool;
@@ -96,35 +105,44 @@ public function __construct(
96105
$this->renderer = $renderer;
97106
$this->questionHelper = $questionHelper;
98107
$this->questionFactory = $questionFactory;
108+
$this->magentoVersion = $magentoVersion;
99109
}
100110

101111
/**
102112
* @inheritDoc
103113
*/
104114
public function run(InputInterface $input, OutputInterface $output)
105115
{
106-
$this->printDetailsInfo($output);
107-
108-
$this->reviewAppliedAction->execute($input, $output, []);
109-
116+
$isJsonFormat = $input->getOption('format') === self::FORMAT_JSON;
110117
$patches = $this->aggregator->aggregate(
111118
array_merge($this->optionalPool->getList(), $this->localPool->getList())
112119
);
113-
foreach ($patches as $patch) {
114-
if ($patch->isDeprecated() && $this->isPatchVisible($patch)) {
115-
$this->printDeprecatedWarning($output, $patch);
120+
121+
if (!$isJsonFormat) {
122+
$this->printDetailsInfo($output);
123+
$this->reviewAppliedAction->execute($input, $output, []);
124+
foreach ($patches as $patch) {
125+
if ($patch->isDeprecated() && $this->isPatchVisible($patch)) {
126+
$this->printDeprecatedWarning($output, $patch);
127+
}
116128
}
117129
}
130+
118131
$patches = $this->filterNotVisiblePatches($patches);
119132

120-
if (count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
133+
if (!$isJsonFormat && count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
121134
$this->printPatchProviders($output, $patches);
122135
$patches = $this->filterByPatchProvider($input, $output, $patches);
123136
$this->printCategoriesInfo($output, $patches);
124137
$patches = $this->filterByPatchCategory($input, $output, $patches);
125138
}
126139

127-
$this->renderer->printTable($output, array_values($patches));
140+
if ($isJsonFormat) {
141+
$this->renderer->printJson($output, array_values($patches));
142+
} else {
143+
$this->renderer->printTable($output, array_values($patches));
144+
$output->writeln('<info>' . $this->magentoVersion->get() . '</info>');
145+
}
128146
}
129147

130148
/**

src/Command/Status.php

+5-12
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\Process\ShowStatus;
12-
use Magento\CloudPatches\Composer\MagentoVersion;
1312
use Psr\Log\LoggerInterface;
13+
use Symfony\Component\Console\Input\InputArgument;
1414
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Input\InputOption;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617

1718
/**
@@ -31,24 +32,16 @@ class Status extends AbstractCommand
3132
*/
3233
private $logger;
3334

34-
/**
35-
* @var MagentoVersion
36-
*/
37-
private $magentoVersion;
38-
3935
/**
4036
* @param ShowStatus $showStatus
4137
* @param LoggerInterface $logger
42-
* @param MagentoVersion $magentoVersion
4338
*/
4439
public function __construct(
4540
ShowStatus $showStatus,
46-
LoggerInterface $logger,
47-
MagentoVersion $magentoVersion
41+
LoggerInterface $logger
4842
) {
4943
$this->showStatus = $showStatus;
5044
$this->logger = $logger;
51-
$this->magentoVersion = $magentoVersion;
5245

5346
parent::__construct(self::NAME);
5447
}
@@ -59,7 +52,8 @@ public function __construct(
5952
protected function configure()
6053
{
6154
$this->setName(self::NAME)
62-
->setDescription('Shows the list of available patches and their statuses');
55+
->setDescription('Shows the list of available patches and their statuses')
56+
->addOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Output format', 'table');
6357

6458
parent::configure();
6559
}
@@ -71,7 +65,6 @@ public function execute(InputInterface $input, OutputInterface $output)
7165
{
7266
try {
7367
$this->showStatus->run($input, $output);
74-
$output->writeln('<info>' . $this->magentoVersion->get() . '</info>');
7568
} catch (RuntimeException $e) {
7669
$output->writeln('<error>' . $e->getMessage() . '</error>');
7770
$this->logger->error($e->getMessage());

0 commit comments

Comments
 (0)