From 1d6e79648e844b45158f46670d2329ed4f1c8593 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Fri, 27 Jul 2018 20:31:55 +0530 Subject: [PATCH 1/3] Correct validation Signed-off-by: Kirtan Gajjar --- src/Cron_Command.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Cron_Command.php b/src/Cron_Command.php index fa65c23..1e74b9a 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -89,7 +89,7 @@ public function add( $args, $assoc_args ) { } } - $this->semi_colon_check( $command ); + $this->validate_command( $command ); $command = $this->add_sh_c_wrapper( $command ); EE::db()->insert( @@ -171,7 +171,7 @@ public function update( $args, $assoc_args ) { $data_to_update['sitename'] = $site; } if ( $command ) { - $this->semi_colon_check( $command ); + $this->validate_command( $command ); $command = $this->add_sh_c_wrapper( $command ); $data_to_update['command'] = $command; } @@ -332,12 +332,18 @@ private function site_php_container( $site ) { return str_replace( '.', '', $site ) . '_php_1'; } - private function semi_colon_check( $command ) { - // Semicolons in commands do not work for now due to limitation of INI style config ofelia uses + /** + * Ensures given command will not create problem with INI syntax + */ + private function validate_command( $command ) { + // Semicolons and Hash(#) in commands do not work for now due to limitation of INI style config ofelia uses // See https://github.com/EasyEngine/cron-command/issues/4 if ( strpos( $command, ';' ) !== false ) { 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.' ); } + if ( strpos( $command, '#' ) !== false ) { + EE::error( 'EasyEngine does not support commands with #' ); + } } private function add_sh_c_wrapper( $command ) { From 7c8d90046aab4601a8d506b5ca97aab8efca0291 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Thu, 2 Aug 2018 14:14:35 +0530 Subject: [PATCH 2/3] Update functional calls Signed-off-by: Riddhesh Sanghvi --- src/Cron_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cron_Command.php b/src/Cron_Command.php index fa65c23..7537de9 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -293,7 +293,7 @@ public function run_now( $args ) { } $container = $this->site_php_container( $result[0]['sitename'] ); $command = $result[0]['command']; - \EE\Utils\default_launch( "docker exec $container $command", true, true ); + EE::exec( "docker exec $container $command", true, true ); } /** From 5133ce164ff41d7532ba80710ccc1249a43346d9 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Mon, 6 Aug 2018 19:25:31 +0530 Subject: [PATCH 3/3] Update to new functional calls Signed-off-by: Riddhesh Sanghvi --- src/Cron_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cron_Command.php b/src/Cron_Command.php index 1e74b9a..fcd4f6e 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -75,7 +75,7 @@ public function add( $args, $assoc_args ) { EE\Utils\delem_log( 'ee cron add start' ); if ( ! isset( $args[0] ) || $args[0] !== 'host' ) { - $args = EE\Utils\set_site_arg( $args, 'cron' ); + $args = EE\SiteUtils\auto_site_name( $args, 'cron', __FUNCTION__ ); } $site = EE\Utils\remove_trailing_slash( $args[0] ); @@ -219,7 +219,7 @@ public function _list( $args, $assoc_args ) { $all = EE\Utils\get_flag_value( $assoc_args, 'all' ); if ( ( ! isset( $args[0] ) || $args[0] !== 'host' ) && ! $all ) { - $args = EE\Utils\set_site_arg( $args, 'cron' ); + $args = EE\SiteUtils\auto_site_name( $args, 'cron', 'list' ); } if ( isset( $args[0] ) ) {