33namespace Makeable \SqlCheck \DbImporter \Databases ;
44
55use Illuminate \Support \Arr ;
6+ use Illuminate \Support \Str ;
67use Makeable \SqlCheck \DbImporter \DbImporter ;
78use Makeable \SqlCheck \DbImporter \Exceptions \DatabaseImportFailed ;
89use Symfony \Component \Process \Exception \ProcessTimedOutException ;
@@ -119,7 +120,7 @@ protected function checkIfImportWasSuccessful($databaseName, $credentials)
119120 {
120121 $ rawTables = $ this ->runMysqlCommand (["USE ` {$ databaseName }` " , 'SHOW TABLES ' ], $ credentials )->getOutput ();
121122
122- if (! starts_with ($ rawTables , 'Tables_in ' ) || ! count (explode (PHP_EOL , $ rawTables )) > 1 ) {
123+ if (! Str:: startsWith ($ rawTables , 'Tables_in ' ) || ! count (explode (PHP_EOL , $ rawTables )) > 1 ) {
123124 throw DatabaseImportFailed::databaseWasEmpty ($ rawTables );
124125 }
125126 }
@@ -137,11 +138,11 @@ protected function runMysqlCommand($mysqlCommands, $credentialsFile, $timeout =
137138
138139 $ command = [
139140 "{$ quote }{$ this ->dumpBinaryPath }mysql {$ quote }" ,
140- "--defaults-extra-file= \" {$ credentialsFile }\" " ,
141+ "--defaults-extra-file=' {$ credentialsFile }' " ,
141142 ];
142143
143144 if ($ this ->socket !== '' ) {
144- $ command [] = "--socket= {$ this ->socket }" ;
145+ $ command [] = "--socket=' {$ this ->socket }' " ;
145146 }
146147
147148 foreach ($ this ->extraOptions as $ extraOption ) {
@@ -150,10 +151,11 @@ protected function runMysqlCommand($mysqlCommands, $credentialsFile, $timeout =
150151
151152 $ command [] = "-e {$ quote }" .implode ('; ' , Arr::wrap ($ mysqlCommands ))."{$ quote }" ;
152153
153- $ process = new Process (implode (' ' , $ command ));
154- $ process ->setTimeout ($ timeout );
154+ $ command = implode (' ' , $ command );
155155
156156 try {
157+ $ process = Process::fromShellCommandline ($ command );
158+ $ process ->setTimeout ($ timeout );
157159 $ process ->run ();
158160 } catch (ProcessTimedOutException $ exception ) {
159161 throw DatabaseImportFailed::timeoutExceeded ($ timeout );
0 commit comments