Skip to content

Commit d47e480

Browse files
committed
Merge branch 'develop' for v3.3.0
2 parents f37e51e + a1be7c3 commit d47e480

File tree

11 files changed

+214
-16
lines changed

11 files changed

+214
-16
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
namespace EE\Migration;
4+
5+
use EE;
6+
use EE\Migration\Base;
7+
use EE\RevertableStepProcessor;
8+
use EE\Model\Site;
9+
10+
class AddExtConfig8_1 extends Base {
11+
12+
private $sites;
13+
/** @var RevertableStepProcessor $rsp Keeps track of migration state. Reverts on error */
14+
private static $rsp;
15+
16+
public function __construct() {
17+
18+
parent::__construct();
19+
$this->sites = Site::all();
20+
if ( $this->is_first_execution || ! $this->sites ) {
21+
$this->skip_this_migration = true;
22+
}
23+
}
24+
25+
public function remove_extension( $config_file_tmp, $config_site_path ) {
26+
if ( $this->fs->exists( $config_file_tmp ) ) {
27+
$this->fs->remove( $config_file_tmp );
28+
}
29+
30+
if ( $this->fs->exists( $config_site_path ) ) {
31+
$this->fs->remove( $config_site_path );
32+
}
33+
}
34+
35+
public function add_extension( $file_name, $extension_name, $site_fs_path ) {
36+
37+
$config_file_tmp = EE\Utils\trailingslashit( EE_BACKUP_DIR ) . $file_name;
38+
$this->fs->dumpFile( $config_file_tmp, "extension=$extension_name" );
39+
40+
$config_site_path = $site_fs_path . '/config/php/php/conf.d/' . $file_name;
41+
42+
self::$rsp->add_step(
43+
"to-$site_fs_path-add-$file_name",
44+
'EE\Migration\SiteContainers::backup_restore',
45+
[ $this, 'remove_extension' ],
46+
[ $config_file_tmp, $config_site_path ],
47+
[ $config_file_tmp, $config_site_path ]
48+
);
49+
50+
if ( ! self::$rsp->execute() ) {
51+
throw new \Exception( 'Unable to run add-ext-config-8.1 upadte migrations.' );
52+
}
53+
54+
$this->fs->remove( $config_file_tmp );
55+
56+
}
57+
58+
/**
59+
* Execute php config updates.
60+
*
61+
* @throws EE\ExitException
62+
*/
63+
public function up() {
64+
65+
if ( $this->skip_this_migration ) {
66+
EE::debug( 'Skipping add-ext-config-8.1 update migration as it is not needed.' );
67+
68+
return;
69+
}
70+
self::$rsp = new RevertableStepProcessor();
71+
72+
foreach ( $this->sites as $site ) {
73+
74+
if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) {
75+
continue;
76+
}
77+
78+
if ( $site->php_version != '8.1' ) {
79+
continue;
80+
}
81+
82+
EE::debug( "Found site: $site->site_url of type: $site->site_type" );
83+
EE::debug( "Starting add-ext-config-8.1 updates for: $site->site_url" );
84+
85+
$this->add_extension(
86+
'docker-php-ext-timezonedb.ini',
87+
'timezonedb',
88+
$site->site_fs_path
89+
);
90+
91+
$this->add_extension(
92+
'docker-php-ext-apcu.ini',
93+
'apcu',
94+
$site->site_fs_path
95+
);
96+
97+
$this->add_extension(
98+
'docker-php-ext-mcrypt.ini',
99+
'mcrypt',
100+
$site->site_fs_path
101+
);
102+
103+
$this->add_extension(
104+
'docker-php-ext-redis.ini',
105+
'redis',
106+
$site->site_fs_path
107+
);
108+
109+
}
110+
}
111+
112+
/**
113+
* Bring back the existing old php config.
114+
*
115+
* @throws EE\ExitException
116+
*/
117+
public function down() {
118+
119+
if ( $this->skip_this_migration ) {
120+
EE::debug( 'Skipping add-ext-config-8.1 update migration as it is not needed.' );
121+
122+
return;
123+
}
124+
125+
foreach ( $this->sites as $site ) {
126+
127+
if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) {
128+
continue;
129+
}
130+
131+
if ( '8.1' != $site->php_version ) {
132+
continue;
133+
}
134+
135+
EE::debug( "Reverting add-ext-config updates for: $site->site_url" );
136+
137+
$configs = [
138+
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-timezonedb.ini',
139+
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-apcu.ini',
140+
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-mcrypt.ini',
141+
$site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-redis.ini',
142+
];
143+
144+
foreach ( $configs as $config ) {
145+
146+
if ( $this->fs->exists( $config ) ) {
147+
$this->fs->remove( $config );
148+
}
149+
}
150+
}
151+
}
152+
153+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace EE\Migration;
4+
5+
use EE;
6+
use EE\Model\Site;
7+
use EE\Migration\Base;
8+
9+
class UpdatePhpVersionEntry74 extends Base {
10+
11+
public function __construct() {
12+
13+
parent::__construct();
14+
$this->sites = Site::all();
15+
if ( $this->is_first_execution || ! $this->sites ) {
16+
$this->skip_this_migration = true;
17+
}
18+
}
19+
20+
/**
21+
* Execute create table query for site and sitemeta table.
22+
*
23+
* @throws EE\ExitException
24+
*/
25+
public function up() {
26+
27+
if ( $this->skip_this_migration ) {
28+
EE::debug( 'Skipping php-version migration as it is not needed.' );
29+
30+
return;
31+
}
32+
foreach ( $this->sites as $site ) {
33+
34+
if ( 'latest' === $site->php_version ) {
35+
$site->php_version = '7.4';
36+
$site->save();
37+
}
38+
}
39+
}
40+
41+
/**
42+
* No changes in case of down.
43+
*
44+
* @throws EE\ExitException
45+
*/
46+
public function down() {
47+
}
48+
49+
}

src/helper/class-ee-site.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
393393
* : Enable wildcard SSL on site.
394394
*
395395
* [--php=<php-version>]
396-
* : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1 and latest.
396+
* : 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.
397397
* ---
398398
* options:
399399
* - 5.6
@@ -403,7 +403,8 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
403403
* - 7.4
404404
* - 8.0
405405
* - 8.1
406-
* - latest
406+
* - 8.2
407+
* - 8.3
407408
* ---
408409
*
409410
* [--proxy-cache=<on-or-off>]
@@ -776,10 +777,6 @@ protected function update_php( $args, $assoc_args ) {
776777

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

779-
if ( '7.4' === $php_version ) {
780-
$php_version = 'latest';
781-
}
782-
783780
if ( $php_version === $this->site_data->php_version ) {
784781
EE::error( 'Site ' . $this->site_data->site_url . ' is already at PHP version: ' . $php_version );
785782
}

src/site-type/HTML.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ public function dump_docker_compose_yml( $additional_filters = [] ) {
330330

331331
$filter = [];
332332
$filter[] = $this->site_data['site_type'];
333+
$filter['site_url'] = $this->site_data['site_url'];
333334
$filter['site_prefix'] = \EE_DOCKER::get_docker_style_prefix( $this->site_data['site_url'] );
334335
$filter['is_ssl'] = $this->site_data['site_ssl'];
335336
$filter['alias_domains'] = implode( ',', array_diff( explode( ',', $this->site_data['alias_domains'] ), [ $this->site_data['site_url'] ] ) );

src/site-type/Site_HTML_Docker.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) {
6464
$nginx['networks'] = [
6565
'net' => [
6666
[ 'name' => 'global-frontend-network' ],
67-
[ 'name' => 'site-network' ],
67+
[ 'name' => $filters['site_url'] ],
6868
],
6969
];
7070

@@ -81,13 +81,14 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) {
8181
$binding = [
8282
'services' => $base,
8383
'network' => [
84+
'name' => $filters['site_url'],
8485
'networks_labels' => [
8586
'label' => [
8687
[ 'name' => 'org.label-schema.vendor=EasyEngine' ],
8788
[ 'name' => 'io.easyengine.site=${VIRTUAL_HOST}' ],
8889
],
8990
],
90-
]
91+
],
9192
];
9293

9394
if ( ! IS_DARWIN ) {

templates/config/php-fpm/php74.zip

2.71 KB
Binary file not shown.

templates/config/php-fpm/php81.zip

1.26 KB
Binary file not shown.

templates/config/php-fpm/php82.zip

82.8 KB
Binary file not shown.

templates/config/php-fpm/php83.zip

82.5 KB
Binary file not shown.
3.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)