Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public function up() {
/**
* Sites wp-config changes for global-cache.
*/
$cache_sites = EE\Model\Site::where( 'cache_host', 'global-redis' );
$cache_sites = EE::db()
->table( 'sites' )
->where( [ [ 'site_type', '==', 'wp' ], [ 'cache_host', '==', 'global-redis' ] ] )
->all();

foreach ( $cache_sites as $site ) {

self::$rsp->add_step(
sprintf( 'update-cache-host-%s', $site->site_url ),
sprintf( 'update-cache-host-%s', $site['site_url'] ),
'EE\Migration\ChangeGlobalServiceContainerNames::update_cache_host',
null,
[ $site ],
Expand Down Expand Up @@ -277,26 +281,26 @@ public static function start_global_service_containers( $containers ) {
/**
* Update redis cache host name.
*
* @param $site_info EE\Model\Site site information.
* @param $site_info array of site information.
*
* @throws \Exception
*/
public static function update_cache_host( $site_info ) {
$update_hostname_constant = "docker-compose exec --user='www-data' php wp config set RT_WP_NGINX_HELPER_REDIS_HOSTNAME global-redis --add=true --type=constant";
$redis_plugin_constant = 'docker-compose exec --user=\'www-data\' php wp config set --type=variable redis_server "array(\'host\'=> \'global-redis\',\'port\'=> 6379,)" --raw';

if ( ! chdir( $site_info->site_fs_path ) ) {
throw new \Exception( sprintf( '%s path not exists', $site_info->site_fs_path ) );
if ( ! chdir( $site_info['site_fs_path'] ) ) {
throw new \Exception( sprintf( '%s path not exists', $site_info['site_fs_path'] ) );
}

if ( ! EE::exec( $update_hostname_constant ) ) {
throw new \Exception( sprintf( 'Unable to update cache host of %s', $site_info->site_url ) );
throw new \Exception( sprintf( 'Unable to update cache host of %s', $site_info['site_url'] ) );
}

if ( ! EE::exec( $redis_plugin_constant ) ) {
throw new \Exception( sprintf( 'Unable to update plugin constant %s', $site_info->site_url ) );
throw new \Exception( sprintf( 'Unable to update plugin constant %s', $site_info['site_url'] ) );
}
EE::log( sprintf( '%s Updated cache-host successfully', $site_info->site_url ) );
EE::log( sprintf( '%s Updated cache-host successfully', $site_info['site_url'] ) );
}

}