Skip to content

[Forwardport] MAGETWO-84608: Cannot perform setup:install if Redis needs a password… #17449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ class Cache implements ConfigOptionsListInterface
const INPUT_KEY_CACHE_BACKEND_REDIS_SERVER = 'cache-backend-redis-server';
const INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE = 'cache-backend-redis-db';
const INPUT_KEY_CACHE_BACKEND_REDIS_PORT = 'cache-backend-redis-port';
const INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD = 'cache-backend-redis-password';

const CONFIG_PATH_CACHE_BACKEND = 'cache/frontend/default/backend';
const CONFIG_PATH_CACHE_BACKEND_SERVER = 'cache/frontend/default/backend_options/server';
const CONFIG_PATH_CACHE_BACKEND_DATABASE = 'cache/frontend/default/backend_options/database';
const CONFIG_PATH_CACHE_BACKEND_PORT = 'cache/frontend/default/backend_options/port';
const CONFIG_PATH_CACHE_BACKEND_PASSWORD = 'cache/frontend/default/backend_options/password';

/**
* @var array
*/
private $defaultConfigValues = [
self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1',
self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => '0',
self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => '6379'
self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => '6379',
self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => ''
];

/**
Expand All @@ -55,6 +58,7 @@ class Cache implements ConfigOptionsListInterface
self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_CACHE_BACKEND_SERVER,
self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_CACHE_BACKEND_DATABASE,
self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_CACHE_BACKEND_PORT,
self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_CACHE_BACKEND_PASSWORD
];

/**
Expand Down Expand Up @@ -102,6 +106,12 @@ public function getOptions()
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_CACHE_BACKEND_PORT,
'Redis server listen port'
),
new TextConfigOption(
self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_CACHE_BACKEND_PASSWORD,
'Redis server password'
)
];
}
Expand Down Expand Up @@ -190,6 +200,13 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen
self::CONFIG_PATH_CACHE_BACKEND_DATABASE,
$this->getDefaultConfigValue(self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE)
);

$config['password'] = isset($options[self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD])
? $options[self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD]
: $deploymentConfig->get(
self::CONFIG_PATH_CACHE_BACKEND_PASSWORD,
$this->getDefaultConfigValue(self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD)
);

return $this->redisValidator->isValidConnection($config);
}
Expand Down
21 changes: 19 additions & 2 deletions setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class PageCache implements ConfigOptionsListInterface
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE = 'page-cache-redis-db';
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT = 'page-cache-redis-port';
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'page-cache-redis-compress-data';
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD = 'page-cache-redis-password';

const CONFIG_PATH_PAGE_CACHE_BACKEND = 'cache/frontend/page_cache/backend';
const CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER = 'cache/frontend/page_cache/backend_options/server';
const CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE = 'cache/frontend/page_cache/backend_options/database';
const CONFIG_PATH_PAGE_CACHE_BACKEND_PORT = 'cache/frontend/page_cache/backend_options/port';
const CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/page_cache/backend_options/compress_data';
const CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD = 'cache/frontend/page_cache/backend_options/password';

/**
* @var array
Expand All @@ -41,7 +43,8 @@ class PageCache implements ConfigOptionsListInterface
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => '1',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => '6379',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => '0'
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => '0',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => ''
];

/**
Expand All @@ -58,7 +61,8 @@ class PageCache implements ConfigOptionsListInterface
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PORT,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD
];

/**
Expand Down Expand Up @@ -112,6 +116,12 @@ public function getOptions()
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA,
'Set to 1 to compress the full page cache (use 0 to disable)'
),
new TextConfigOption(
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD,
'Redis server password'
)
];
}
Expand Down Expand Up @@ -201,6 +211,13 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen
self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE,
$this->getDefaultConfigValue(self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE)
);

$config['password'] = isset($options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD])
? $options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD]
: $deploymentConfig->get(
self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD,
$this->getDefaultConfigValue(self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD)
);

return $this->redisValidator->isValidConnection($config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function testGetOptions()
$this->assertArrayHasKey(3, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[3]);
$this->assertEquals('cache-backend-redis-port', $options[3]->getName());

$this->assertArrayHasKey(4, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[4]);
$this->assertEquals('cache-backend-redis-password', $options[4]->getName());
}

public function testCreateConfigCacheRedis()
Expand All @@ -70,7 +74,8 @@ public function testCreateConfigCacheRedis()
'backend_options' => [
'server' => '',
'port' => '',
'database' => ''
'database' => '',
'password' => ''
]
]
]
Expand All @@ -92,7 +97,8 @@ public function testCreateConfigWithRedisConfig()
'backend_options' => [
'server' => 'localhost',
'port' => '1234',
'database' => '5'
'database' => '5',
'password' => ''
]
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public function testGetOptions()
$this->assertArrayHasKey(4, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[4]);
$this->assertEquals('page-cache-redis-compress-data', $options[4]->getName());

$this->assertArrayHasKey(5, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[5]);
$this->assertEquals('page-cache-redis-password', $options[5]->getName());
}

public function testCreateConfigWithRedis()
Expand All @@ -75,7 +79,8 @@ public function testCreateConfigWithRedis()
'server'=> '',
'port' => '',
'database' => '',
'compress_data' => ''
'compress_data' => '',
'password' => ''
]
]
]
Expand All @@ -98,7 +103,8 @@ public function testCreateConfigWithRedisConfiguration()
'server' => 'foo.bar',
'port' => '9000',
'database' => '6',
'compress_data' => '1'
'compress_data' => '1',
'password' => ''
]
]
]
Expand Down