22
33namespace Drush \Sql ;
44
5+ use Consolidation \SiteProcess \Util \Escape ;
6+ use Consolidation \SiteProcess \Util \Shell ;
57use Drupal \Core \Database \Database ;
68use Drush \Drush ;
7- use Drush \Log \LogLevel ;
89use Drush \Utils \FsUtils ;
910use Robo \Common \ConfigAwareTrait ;
1011use Robo \Contract \ConfigAwareInterface ;
12+ use Symfony \Component \Filesystem \Filesystem ;
1113use Symfony \Component \Process \Process ;
1214use Webmozart \PathUtil \Path ;
1315
@@ -29,7 +31,10 @@ class SqlBase implements ConfigAwareInterface
2931 // An options array.
3032 public $ options ;
3133
32- public $ process ;
34+ /**
35+ * @var Process
36+ */
37+ protected $ process ;
3338
3439 /**
3540 * Typically, SqlBase instances are constructed via SqlBase::create($options).
@@ -169,7 +174,7 @@ public function dump()
169174 }
170175 if ($ file ) {
171176 $ file .= $ file_suffix ;
172- $ cmd .= ' > ' . drush_escapeshellarg ($ file );
177+ $ cmd .= ' > ' . Escape:: shellArg ($ file );
173178 }
174179
175180 $ process = Drush::process ($ cmd );
@@ -247,7 +252,7 @@ public function query($query, $input_file = null, $result_file = '')
247252 /**
248253 * Execute a SQL query. Always execute regardless of simulate mode.
249254 *
250- * If you don't want query results to print during --debug then
255+ * If you don't want query to print during --debug then
251256 * provide a $result_file whose value can be drush_bit_bucket().
252257 *
253258 * @param string $query
@@ -276,7 +281,7 @@ public function alwaysQuery($query, $input_file = null, $result_file = '')
276281 }
277282 }
278283
279- // Save $query to a tmp file if needed. We will redirect it in.
284+ // Save $query to a tmp file if needed. We redirect it in.
280285 if (!$ input_file ) {
281286 $ query = $ this ->queryPrefix ($ query );
282287 $ query = $ this ->queryFormat ($ query );
@@ -289,12 +294,12 @@ public function alwaysQuery($query, $input_file = null, $result_file = '')
289294 $ this ->silent (), // This removes column header and various helpful things in mysql.
290295 $ this ->getOption ('extra ' , $ this ->queryExtra ),
291296 $ this ->queryFile ,
292- drush_escapeshellarg ($ input_file ),
297+ Escape:: shellArg ($ input_file ),
293298 ];
294299 $ exec = implode (' ' , $ parts );
295300
296301 if ($ result_file ) {
297- $ exec .= ' > ' . drush_escapeshellarg ($ result_file );
302+ $ exec .= ' > ' . Escape:: shellArg ($ result_file );
298303 }
299304
300305 // In --verbose mode, drush_shell_exec() will show the call to mysql/psql/sqlite,
@@ -309,7 +314,8 @@ public function alwaysQuery($query, $input_file = null, $result_file = '')
309314 $ this ->setProcess ($ process );
310315
311316 if ($ success && $ this ->getOption ('file-delete ' )) {
312- drush_delete_dir ($ input_file );
317+ $ fs = new Filesystem ();
318+ $ fs ->remove ($ input_file );
313319 }
314320
315321 return $ success ;
0 commit comments