Skip to content

Commit

Permalink
Merge pull request #11 from magento-commerce/develop
Browse files Browse the repository at this point in the history
Merge develop into 1.0
  • Loading branch information
oshmyheliuk authored Jul 20, 2021
2 parents 86fc24f + 56b96f5 commit 6dca123
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
env:
- TEST_SUITE=functional

before_install:
# https://github.com/kylekatarnls/update-helper/issues/9
- if [ -n "${COMPOSER_VERSION}" ]; then travis_retry composer self-update ${COMPOSER_VERSION}; fi;

install:
- composer config github-oauth.github.com ${GITHUB_TOKEN}
Expand Down
51 changes: 43 additions & 8 deletions Model/Cache/Evictor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Evictor
const DEFAULT_SLEEP_TIMEOUT = 20000;
const CONFIG_PATH_ENABLED = 'cache_evict/enabled';
const CONFIG_PATH_LIMIT = 'cache_evict/limit';
const BACKEND_OPTION_KEY_SERVER = 'server';
const BACKEND_OPTION_KEY_PORT = 'port';
const BACKEND_OPTION_KEY_DATABASE = 'database';

/**
* @var DeploymentConfig
Expand Down Expand Up @@ -60,11 +63,8 @@ public function evict(): int
$name
));

if (!isset(
$cacheConfig['backend_options']['server'],
$cacheConfig['backend_options']['port'],
$cacheConfig['backend_options']['database']
)) {
$backendOptions = $this->getConfigBackendOptions((array)$cacheConfig);
if (!$this->validateBackendOptions($backendOptions)) {
$this->logger->debug(sprintf(
'Cache config for database "%s" config is not valid',
$name
Expand All @@ -74,9 +74,9 @@ public function evict(): int
}

$dbKeys = $this->run(
(string)$cacheConfig['backend_options']['server'],
(int)$cacheConfig['backend_options']['port'],
(int)$cacheConfig['backend_options']['database']
(string)$backendOptions[self::BACKEND_OPTION_KEY_SERVER],
(int)$backendOptions[self::BACKEND_OPTION_KEY_PORT],
(int)$backendOptions[self::BACKEND_OPTION_KEY_DATABASE]
);
$evictedKeys += $dbKeys;

Expand All @@ -86,6 +86,41 @@ public function evict(): int
return $evictedKeys;
}

/**
* Get Cache Config Value
*
* @param array $cacheConfig
* @return array
*/
private function getConfigBackendOptions(array $cacheConfig): array
{
$backendOptions = [];
if (isset($cacheConfig['backend_options'])) {
$backendOptions = $cacheConfig['backend_options'];
}
if (isset($cacheConfig['backend_options']['remote_backend_options'])) {
$backendOptions = $cacheConfig['backend_options']['remote_backend_options'];
}
return (array)$backendOptions;
}

/**
* Validate Cache Configuration
*
* @param array $backendOptions
* @return bool
*/
private function validateBackendOptions(array $backendOptions): bool
{
if (isset($backendOptions[self::BACKEND_OPTION_KEY_SERVER])
&& isset($backendOptions[self::BACKEND_OPTION_KEY_PORT])
&& isset($backendOptions[self::BACKEND_OPTION_KEY_DATABASE])
) {
return true;
}
return false;
}

/**
* @param string $host
* @param int $port
Expand Down
1 change: 1 addition & 0 deletions Model/Cache/InvalidateLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class InvalidateLogger extends \Magento\Framework\Cache\InvalidateLogger
'acl_cache',
'reflection',
'db_ddl',
'LOCKED_RECORD_INFO_SYSTEM_CONFIG',
'all'
];

Expand Down
1 change: 1 addition & 0 deletions Model/Observer/CacheFlushAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(InvalidateLogger $logger)
* Log cache flush action to a file
*
* @param Observer $observer
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(Observer $observer)
{
Expand Down
2 changes: 1 addition & 1 deletion Model/UrlFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function run(Store $store, $url): string
return preg_replace('|/magento/|', '/', $url, 1);
}

return $url;
return rtrim($url, '/');
}
}
2 changes: 1 addition & 1 deletion Test/Functional/Acceptance/AcceptanceCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testPatches(\CliTester $I, \Codeception\Example $data): void
{
$this->prepareTemplate($I, $data['magentoVersion']);
$this->removeESIfExists($I, $data['magentoVersion']);
$I->runEceDockerCommand('build:compose --mode=production');
$I->generateDockerCompose('--mode=production');
$I->runDockerComposeCommand('run build cloud-build');
$I->startEnvironment();
$I->runDockerComposeCommand('run deploy cloud-deploy');
Expand Down
10 changes: 5 additions & 5 deletions Test/Unit/Model/UrlFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ public function runDataProvider(): array
return [
'rewrites enabled, url without "magento" part' => [
'http://example.com/',
'http://example.com/',
'http://example.com',
],
'rewrites disabled, url without "magento" part' => [
'http://example.com/',
'http://example.com/',
'http://example.com',
true,
true,
],
'rewrites enabled, url with "magento" part' => [
'http://example.com/magento/',
'http://example.com/magento/',
'http://example.com/magento',
false,
true,
],
Expand All @@ -108,13 +108,13 @@ public function runDataProvider(): array
],
'rewrites disabled, url with "magento2" part' => [
'http://example.com/magento2/',
'http://example.com/magento2/',
'http://example.com/magento2',
true,
false,
],
'rewrites disabled, with "magento" host' => [
'http://magento.com/magento2/',
'http://magento.com/magento2/',
'http://magento.com/magento2',
true,
false,
],
Expand Down
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-components",
"description": "Cloud Components Module for Magento 2.x",
"type": "magento2-module",
"version": "1.0.7",
"version": "1.0.8",
"require": {
"php": "^7.0",
"ext-json": "*",
Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
</arguments>
</type>
<type name="Magento\Framework\Indexer\ActionInterface">
<plugin name="cache_cleaner_after_reindex" type="Magento\CloudComponents\Model\Indexation\Logger" />
<plugin name="cache_logger_after_reindex" type="Magento\CloudComponents\Model\Indexation\Logger" />
</type>
</config>
1 change: 1 addition & 0 deletions travis.php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_limit = 4G

0 comments on commit 6dca123

Please sign in to comment.