File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change 2727 $ magentoBinary = $ php . ' -f ../../../../bin/magento ' ;
2828 $ valid = validateCommand ($ magentoBinary , $ command );
2929 if ($ valid ) {
30- exec (
31- escapeCommand ($ magentoBinary . " $ command " . " $ arguments " ) . " 2>&1 " ,
32- $ output ,
33- $ exitCode
34- );
35- if ($ exitCode == 0 ) {
30+ $ process = new Symfony \Component \Process \Process ($ magentoBinary . " $ command " . " $ arguments " );
31+ $ process ->setIdleTimeout (60 );
32+ $ process ->setTimeout (0 );
33+ $ idleTimeout = false ;
34+ try {
35+ $ process ->run ();
36+ $ output = $ process ->getOutput ();
37+ if (!$ process ->isSuccessful ()) {
38+ $ output = $ process ->getErrorOutput ();
39+ }
40+ if (empty ($ output )) {
41+ $ output = "CLI did not return output. " ;
42+ }
43+
44+ } catch (Symfony \Component \Process \Exception \ProcessTimedOutException $ exception ) {
45+ $ output = "CLI command timed out, no output available. " ;
46+ $ idleTimeout = true ;
47+ }
48+ $ exitCode = $ process ->getExitCode ();
49+
50+ if ($ exitCode == 0 || $ idleTimeout ) {
3651 http_response_code (202 );
3752 } else {
3853 http_response_code (500 );
3954 }
40- echo implode ( "\n" , $ output) ;
55+ echo $ output ;
4156 } else {
4257 http_response_code (403 );
4358 echo "Given command not found valid in Magento CLI Command list. " ;
You can’t perform that action at this time.
0 commit comments