Skip to content

Commit

Permalink
Merge pull request #65 from magento-commerce/develop
Browse files Browse the repository at this point in the history
MCLOUD-9560: October cloud tools release
  • Loading branch information
BaDos authored Oct 24, 2022
2 parents 38a601e + 138c65e commit 39d1968
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 185 deletions.
96 changes: 0 additions & 96 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento-cloud-patches",
"description": "Provides critical fixes for Magento 2 Enterprise Edition",
"type": "magento2-component",
"version": "1.0.19",
"version": "1.0.20",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
Expand Down
3 changes: 2 additions & 1 deletion patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
">=2.3.3-p1 <2.3.4": "MCLOUD-6139_MCLOUD-6211__redis_improvement_patches__2.3.3-p1.patch",
">=2.3.4 <2.3.5": "MCLOUD-6139_MCLOUD-6211__redis_improvement_patches__2.3.4.patch",
">=2.3.5 <2.3.6": "MCLOUD-6211__redis_improvement_patches__2.3.5.patch",
">=2.4.0 <2.4.1": "MCLOUD-6659__fix_L2_redis_cache__2.4.0.patch"
">=2.4.0 <2.4.1": "MCLOUD-6659__fix_L2_redis_cache__2.4.0.patch",
">=2.4.1 <2.4.2": "MCLOUD-7845__fix_local_flushing_L2_cache__2.4.0.patch"
},
"Incompatible PHP Method Fix": {
"2.3.7-p1": "AC-384__Fix_Incompatible_PHP_Method__2.3.7-p1_ce.patch",
Expand Down
36 changes: 35 additions & 1 deletion patches/MCLOUD-6659__fix_L2_redis_cache__2.4.0.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
--- a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
+++ b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
@@ -205,7 +205,7 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
@@ -237,7 +237,7 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
$dataToSave = $data;
$remHash = $this->loadRemoteDataVersion($id);

Expand All @@ -10,3 +10,37 @@ diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
$dataToSave = $this->remote->load($id);
} else {
$this->remote->save($data, $id, $tags, $specificLifetime);
@@ -248,9 +248,23 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
$this->unlock($id);
}

+ if (!mt_rand(0, 100) && $this->checkIfLocalCacheSpaceExceeded()) {
+ $this->local->clean();
+ }
+
return $this->local->save($dataToSave, $id, [], $specificLifetime);
}

+ /**
+ * Check if local cache space bigger that configure amount
+ *
+ * @return bool
+ */
+ private function checkIfLocalCacheSpaceExceeded()
+ {
+ return $this->getFillingPercentage() >= 95;
+ }
+
/**
* @inheritdoc
*/
@@ -266,7 +280,8 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
{
- return $this->remote->clean($mode, $tags);
+ return $this->remote->clean($mode, $tags) &&
+ $this->local->clean($mode, $tags);
}

/**
38 changes: 38 additions & 0 deletions patches/MCLOUD-7845__fix_local_flushing_L2_cache__2.4.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff -Nuar a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
index d0c05613..96f7ad84 100644
--- a/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
+++ b/vendor/magento/framework/Cache/Backend/RemoteSynchronizedCache.php
@@ -248,9 +248,23 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
$this->unlock($id);
}

+ if (!mt_rand(0, 100) && $this->checkIfLocalCacheSpaceExceeded()) {
+ $this->local->clean();
+ }
+
return $this->local->save($dataToSave, $id, [], $specificLifetime);
}

+ /**
+ * Check if local cache space bigger that configure amount
+ *
+ * @return bool
+ */
+ private function checkIfLocalCacheSpaceExceeded()
+ {
+ return $this->getFillingPercentage() >= 95;
+ }
+
/**
* @inheritdoc
*/
@@ -266,7 +280,8 @@ class RemoteSynchronizedCache extends \Zend_Cache_Backend implements \Zend_Cache
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
{
- return $this->remote->clean($mode, $tags);
+ return $this->remote->clean($mode, $tags) &&
+ $this->local->clean($mode, $tags);
}

/**
35 changes: 35 additions & 0 deletions src/Command/Process/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ public function printTable(OutputInterface $output, array $patchList)
$table->render();
}

/**
* Renders patches list as JSON.
*
* @param OutputInterface $output
* @param AggregatedPatchInterface[] $patchList
* @return void
*/
public function printJson(OutputInterface $output, array $patchList)
{
$rows = [];
foreach ($patchList as $patch) {
$rows[] = $this->createJsonRow($patch);
}

usort($rows, function ($a, $b) {
if ($a[self::STATUS] === $b[self::STATUS]) {
return strcmp($a[self::ORIGIN], $b[self::ORIGIN]);
}
return strcmp($a[self::STATUS], $b[self::STATUS]);
});

$output->writeln(json_encode($rows, JSON_PRETTY_PRINT));
}

/**
* Print patch info.
*
Expand Down Expand Up @@ -209,6 +233,17 @@ function ($item) {
];
}

/**
* Creates JSON row.
*
* @param AggregatedPatchInterface $patch
* @return array
*/
private function createJsonRow(AggregatedPatchInterface $patch): array
{
return array_map('strip_tags', $this->createRow($patch));
}

/**
* Adds table separator.
*
Expand Down
38 changes: 28 additions & 10 deletions src/Command/Process/ShowStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\CloudPatches\Command\Process;

use Magento\CloudPatches\Command\Process\Action\ReviewAppliedAction;
use Magento\CloudPatches\Composer\MagentoVersion;
use Magento\CloudPatches\Console\QuestionFactory;
use Magento\CloudPatches\Patch\Data\AggregatedPatch;
use Magento\CloudPatches\Patch\Data\AggregatedPatchInterface;
Expand All @@ -28,6 +29,8 @@ class ShowStatus implements ProcessInterface

const FILTER_OPTION_ALL = 'All';

const FORMAT_JSON = 'json';

/**
* @var Aggregator
*/
Expand All @@ -43,6 +46,11 @@ class ShowStatus implements ProcessInterface
*/
private $localPool;

/**
* @var MagentoVersion
*/
private $magentoVersion;

/**
* @var StatusPool
*/
Expand Down Expand Up @@ -86,7 +94,8 @@ public function __construct(
ReviewAppliedAction $reviewAppliedAction,
Renderer $renderer,
QuestionHelper $questionHelper,
QuestionFactory $questionFactory
QuestionFactory $questionFactory,
MagentoVersion $magentoVersion
) {
$this->aggregator = $aggregator;
$this->optionalPool = $optionalPool;
Expand All @@ -96,35 +105,44 @@ public function __construct(
$this->renderer = $renderer;
$this->questionHelper = $questionHelper;
$this->questionFactory = $questionFactory;
$this->magentoVersion = $magentoVersion;
}

/**
* @inheritDoc
*/
public function run(InputInterface $input, OutputInterface $output)
{
$this->printDetailsInfo($output);

$this->reviewAppliedAction->execute($input, $output, []);

$isJsonFormat = $input->getOption('format') === self::FORMAT_JSON;
$patches = $this->aggregator->aggregate(
array_merge($this->optionalPool->getList(), $this->localPool->getList())
);
foreach ($patches as $patch) {
if ($patch->isDeprecated() && $this->isPatchVisible($patch)) {
$this->printDeprecatedWarning($output, $patch);

if (!$isJsonFormat) {
$this->printDetailsInfo($output);
$this->reviewAppliedAction->execute($input, $output, []);
foreach ($patches as $patch) {
if ($patch->isDeprecated() && $this->isPatchVisible($patch)) {
$this->printDeprecatedWarning($output, $patch);
}
}
}

$patches = $this->filterNotVisiblePatches($patches);

if (count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
if (!$isJsonFormat && count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
$this->printPatchProviders($output, $patches);
$patches = $this->filterByPatchProvider($input, $output, $patches);
$this->printCategoriesInfo($output, $patches);
$patches = $this->filterByPatchCategory($input, $output, $patches);
}

$this->renderer->printTable($output, array_values($patches));
if ($isJsonFormat) {
$this->renderer->printJson($output, array_values($patches));
} else {
$this->renderer->printTable($output, array_values($patches));
$output->writeln('<info>' . $this->magentoVersion->get() . '</info>');
}
}

/**
Expand Down
17 changes: 5 additions & 12 deletions src/Command/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

use Magento\CloudPatches\App\RuntimeException;
use Magento\CloudPatches\Command\Process\ShowStatus;
use Magento\CloudPatches\Composer\MagentoVersion;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand All @@ -31,24 +32,16 @@ class Status extends AbstractCommand
*/
private $logger;

/**
* @var MagentoVersion
*/
private $magentoVersion;

/**
* @param ShowStatus $showStatus
* @param LoggerInterface $logger
* @param MagentoVersion $magentoVersion
*/
public function __construct(
ShowStatus $showStatus,
LoggerInterface $logger,
MagentoVersion $magentoVersion
LoggerInterface $logger
) {
$this->showStatus = $showStatus;
$this->logger = $logger;
$this->magentoVersion = $magentoVersion;

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

parent::configure();
}
Expand All @@ -71,7 +65,6 @@ public function execute(InputInterface $input, OutputInterface $output)
{
try {
$this->showStatus->run($input, $output);
$output->writeln('<info>' . $this->magentoVersion->get() . '</info>');
} catch (RuntimeException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
$this->logger->error($e->getMessage());
Expand Down
Loading

0 comments on commit 39d1968

Please sign in to comment.