Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update functions according to db refactoring #5

Merged
merged 3 commits into from
Aug 22, 2018
Merged
Changes from 2 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
17 changes: 9 additions & 8 deletions src/Shell_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ class Shell_Command extends EE_Command {
*/
public function __invoke( $args ) {
EE\Utils\delem_log( 'ee shell start' );
$args = EE\Utils\set_site_arg( $args, 'shell' );
$args = EE\SiteUtils\auto_site_name( $args, 'shell', '' );
$site_name = EE\Utils\remove_trailing_slash( $args[0] );
if ( EE::db()::site_in_db( $site_name ) ) {
$db_select = EE::db()::select( ['site_path'], ['sitename' => $site_name]);
$site_root = $db_select[0]['site_path'];
} else {

$site = Site::find( $site_name );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Site::find is not a sufficient check. The site needs to be present as well as enabled otherwise the opening it's shell will not be possible. Create a model maybe Site::enabled that checks precisely both the things. It is required in almost all the commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if ( ! $site ) {
EE::error( "Site $site_name does not exist." );
}
chdir($site_root);

chdir( $site->site_fs_path );
$this->run( "docker-compose exec --user='www-data' php bash" );
EE\Utils\delem_log( 'ee shell end' );
}
Expand All @@ -43,9 +44,9 @@ private function run( $cmd, $descriptors = null ) {
if ( ! $descriptors ) {
$descriptors = array( STDIN, STDOUT, STDERR );
}

$final_cmd = EE\Utils\force_env_on_nix_systems( $cmd );
$proc = EE\Utils\proc_open_compat( $final_cmd, $descriptors, $pipes );
$proc = EE\Utils\proc_open_compat( $final_cmd, $descriptors, $pipes );
if ( ! $proc ) {
exit( 1 );
}
Expand Down