Skip to content

Commit 7dae17a

Browse files
committed
Merge branch 'develop' for v1.0.0-beta.2
2 parents 34b27c0 + 8bc1437 commit 7dae17a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Cron_Command.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function add( $args, $assoc_args ) {
7575
EE\Utils\delem_log( 'ee cron add start' );
7676

7777
if ( ! isset( $args[0] ) || $args[0] !== 'host' ) {
78-
$args = EE\Utils\set_site_arg( $args, 'cron' );
78+
$args = EE\SiteUtils\auto_site_name( $args, 'cron', __FUNCTION__ );
7979
}
8080

8181
$site = EE\Utils\remove_trailing_slash( $args[0] );
@@ -89,7 +89,7 @@ public function add( $args, $assoc_args ) {
8989
}
9090
}
9191

92-
$this->semi_colon_check( $command );
92+
$this->validate_command( $command );
9393
$command = $this->add_sh_c_wrapper( $command );
9494

9595
EE::db()->insert(
@@ -171,7 +171,7 @@ public function update( $args, $assoc_args ) {
171171
$data_to_update['sitename'] = $site;
172172
}
173173
if ( $command ) {
174-
$this->semi_colon_check( $command );
174+
$this->validate_command( $command );
175175
$command = $this->add_sh_c_wrapper( $command );
176176
$data_to_update['command'] = $command;
177177
}
@@ -219,7 +219,7 @@ public function _list( $args, $assoc_args ) {
219219
$all = EE\Utils\get_flag_value( $assoc_args, 'all' );
220220

221221
if ( ( ! isset( $args[0] ) || $args[0] !== 'host' ) && ! $all ) {
222-
$args = EE\Utils\set_site_arg( $args, 'cron' );
222+
$args = EE\SiteUtils\auto_site_name( $args, 'cron', 'list' );
223223
}
224224

225225
if ( isset( $args[0] ) ) {
@@ -293,7 +293,7 @@ public function run_now( $args ) {
293293
}
294294
$container = $this->site_php_container( $result[0]['sitename'] );
295295
$command = $result[0]['command'];
296-
\EE\Utils\default_launch( "docker exec $container $command", true, true );
296+
EE::exec( "docker exec $container $command", true, true );
297297
}
298298

299299
/**
@@ -332,12 +332,18 @@ private function site_php_container( $site ) {
332332
return str_replace( '.', '', $site ) . '_php_1';
333333
}
334334

335-
private function semi_colon_check( $command ) {
336-
// Semicolons in commands do not work for now due to limitation of INI style config ofelia uses
335+
/**
336+
* Ensures given command will not create problem with INI syntax
337+
*/
338+
private function validate_command( $command ) {
339+
// Semicolons and Hash(#) in commands do not work for now due to limitation of INI style config ofelia uses
337340
// See https://github.com/EasyEngine/cron-command/issues/4
338341
if ( strpos( $command, ';' ) !== false ) {
339342
EE::error( 'Command chaining using `;` - semi-colon is not supported currently. You can either use `&&` or `||` or creating a second cron job for the chained command.' );
340343
}
344+
if ( strpos( $command, '#' ) !== false ) {
345+
EE::error( 'EasyEngine does not support commands with #' );
346+
}
341347
}
342348

343349
private function add_sh_c_wrapper( $command ) {

0 commit comments

Comments
 (0)