Skip to content

Commit

Permalink
Merge branch 'develop' for v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrobot47 committed May 14, 2024
2 parents f37e51e + a1be7c3 commit d47e480
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

namespace EE\Migration;

use EE;
use EE\Migration\Base;
use EE\RevertableStepProcessor;
use EE\Model\Site;

class AddExtConfig8_1 extends Base {

private $sites;
/** @var RevertableStepProcessor $rsp Keeps track of migration state. Reverts on error */
private static $rsp;

public function __construct() {

parent::__construct();
$this->sites = Site::all();
if ( $this->is_first_execution || ! $this->sites ) {
$this->skip_this_migration = true;
}
}

public function remove_extension( $config_file_tmp, $config_site_path ) {
if ( $this->fs->exists( $config_file_tmp ) ) {
$this->fs->remove( $config_file_tmp );
}

if ( $this->fs->exists( $config_site_path ) ) {
$this->fs->remove( $config_site_path );
}
}

public function add_extension( $file_name, $extension_name, $site_fs_path ) {

$config_file_tmp = EE\Utils\trailingslashit( EE_BACKUP_DIR ) . $file_name;
$this->fs->dumpFile( $config_file_tmp, "extension=$extension_name" );

$config_site_path = $site_fs_path . '/config/php/php/conf.d/' . $file_name;

self::$rsp->add_step(
"to-$site_fs_path-add-$file_name",
'EE\Migration\SiteContainers::backup_restore',
[ $this, 'remove_extension' ],
[ $config_file_tmp, $config_site_path ],
[ $config_file_tmp, $config_site_path ]
);

if ( ! self::$rsp->execute() ) {
throw new \Exception( 'Unable to run add-ext-config-8.1 upadte migrations.' );
}

$this->fs->remove( $config_file_tmp );

}

/**
* Execute php config updates.
*
* @throws EE\ExitException
*/
public function up() {

if ( $this->skip_this_migration ) {
EE::debug( 'Skipping add-ext-config-8.1 update migration as it is not needed.' );

return;
}
self::$rsp = new RevertableStepProcessor();

foreach ( $this->sites as $site ) {

if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) {
continue;
}

if ( $site->php_version != '8.1' ) {
continue;
}

EE::debug( "Found site: $site->site_url of type: $site->site_type" );
EE::debug( "Starting add-ext-config-8.1 updates for: $site->site_url" );

$this->add_extension(
'docker-php-ext-timezonedb.ini',
'timezonedb',
$site->site_fs_path
);

$this->add_extension(
'docker-php-ext-apcu.ini',
'apcu',
$site->site_fs_path
);

$this->add_extension(
'docker-php-ext-mcrypt.ini',
'mcrypt',
$site->site_fs_path
);

$this->add_extension(
'docker-php-ext-redis.ini',
'redis',
$site->site_fs_path
);

}
}

/**
* Bring back the existing old php config.
*
* @throws EE\ExitException
*/
public function down() {

if ( $this->skip_this_migration ) {
EE::debug( 'Skipping add-ext-config-8.1 update migration as it is not needed.' );

return;
}

foreach ( $this->sites as $site ) {

if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) {
continue;
}

if ( '8.1' != $site->php_version ) {
continue;
}

EE::debug( "Reverting add-ext-config updates for: $site->site_url" );

$configs = [
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-timezonedb.ini',
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-apcu.ini',
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-mcrypt.ini',
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-redis.ini',
];

foreach ( $configs as $config ) {

if ( $this->fs->exists( $config ) ) {
$this->fs->remove( $config );
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace EE\Migration;

use EE;
use EE\Model\Site;
use EE\Migration\Base;

class UpdatePhpVersionEntry74 extends Base {

public function __construct() {

parent::__construct();
$this->sites = Site::all();
if ( $this->is_first_execution || ! $this->sites ) {
$this->skip_this_migration = true;
}
}

/**
* Execute create table query for site and sitemeta table.
*
* @throws EE\ExitException
*/
public function up() {

if ( $this->skip_this_migration ) {
EE::debug( 'Skipping php-version migration as it is not needed.' );

return;
}
foreach ( $this->sites as $site ) {

if ( 'latest' === $site->php_version ) {
$site->php_version = '7.4';
$site->save();
}
}
}

/**
* No changes in case of down.
*
* @throws EE\ExitException
*/
public function down() {
}

}
9 changes: 3 additions & 6 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
* : Enable wildcard SSL on site.
*
* [--php=<php-version>]
* : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1 and latest.
* : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 and 8.3.
* ---
* options:
* - 5.6
Expand All @@ -403,7 +403,8 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
* - 7.4
* - 8.0
* - 8.1
* - latest
* - 8.2
* - 8.3
* ---
*
* [--proxy-cache=<on-or-off>]
Expand Down Expand Up @@ -776,10 +777,6 @@ protected function update_php( $args, $assoc_args ) {

$php_version = get_flag_value( $assoc_args, 'php', false );

if ( '7.4' === $php_version ) {
$php_version = 'latest';
}

if ( $php_version === $this->site_data->php_version ) {
EE::error( 'Site ' . $this->site_data->site_url . ' is already at PHP version: ' . $php_version );
}
Expand Down
1 change: 1 addition & 0 deletions src/site-type/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public function dump_docker_compose_yml( $additional_filters = [] ) {

$filter = [];
$filter[] = $this->site_data['site_type'];
$filter['site_url'] = $this->site_data['site_url'];
$filter['site_prefix'] = \EE_DOCKER::get_docker_style_prefix( $this->site_data['site_url'] );
$filter['is_ssl'] = $this->site_data['site_ssl'];
$filter['alias_domains'] = implode( ',', array_diff( explode( ',', $this->site_data['alias_domains'] ), [ $this->site_data['site_url'] ] ) );
Expand Down
5 changes: 3 additions & 2 deletions src/site-type/Site_HTML_Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) {
$nginx['networks'] = [
'net' => [
[ 'name' => 'global-frontend-network' ],
[ 'name' => 'site-network' ],
[ 'name' => $filters['site_url'] ],
],
];

Expand All @@ -81,13 +81,14 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) {
$binding = [
'services' => $base,
'network' => [
'name' => $filters['site_url'],
'networks_labels' => [
'label' => [
[ 'name' => 'org.label-schema.vendor=EasyEngine' ],
[ 'name' => 'io.easyengine.site=${VIRTUAL_HOST}' ],
],
],
]
],
];

if ( ! IS_DARWIN ) {
Expand Down
Binary file modified templates/config/php-fpm/php74.zip
Binary file not shown.
Binary file modified templates/config/php-fpm/php81.zip
Binary file not shown.
Binary file added templates/config/php-fpm/php82.zip
Binary file not shown.
Binary file added templates/config/php-fpm/php83.zip
Binary file not shown.
Binary file modified templates/config/php-fpm/phplatest.zip
Binary file not shown.
13 changes: 5 additions & 8 deletions templates/docker-compose.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.5'

services:

{{#services}}
Expand Down Expand Up @@ -63,22 +61,21 @@ services:
volumes:
{{#external_vols}}
{{ext_vol_name}}:
external:
name: {{prefix}}_{{ext_vol_name}}
external: true
name: {{prefix}}_{{ext_vol_name}}
{{/external_vols}}
{{/created_volumes}}

{{#network}}
networks:
site-network:
name: ${VIRTUAL_HOST}
{{name}}:
{{#networks_labels}}
labels:
{{#label}}
- "{{name}}"
{{/label}}
{{/networks_labels}}
global-frontend-network:
external:
name: ee-global-frontend-network
external: true
name: ee-global-frontend-network
{{/network}}

0 comments on commit d47e480

Please sign in to comment.