<commit_before><?php

/**
 * @file
 * Contains \Docker\Drupal\Extension\DemoCommand.
 */

namespace Docker\Drupal\Extension;

use Docker\Drupal\Application;

const DEV_MYSQL_PASS = '<PASSWORD>';
const LOCALHOST = '127.0.0.1';

/**
 * Class ApplicationConfigExtension
 * @package Docker\Drupal\Extension
 */
class ApplicationConfigExtension extends Application {

  /**
   * Verify mySQL container is ready.
   *
   * @param $io
   * @param $system_appname
   * @param $type
   */
  function verifyMySQL($io, $system_appname, $type) {
    // Check for running mySQL container before launching Drupal Installation.
    $io->text(' ');
    $io->warning('Waiting for mySQL service.');

    if ($type) {
      switch ($type) {
        case 'prod':
          $command = exec('docker port mysql 3306');
          $port = explode(':', $command);
          $db_port = $port[1];
          $db_name = 'prod';
          break;

        case 'stage':
          $command = "docker-compose -f docker_" . $system_appname . "/docker-compose-data.yml --project-name=" . $system_appname . "_data port db 3306";
          $port_info = exec($command);
          $port = explode(':', $port_info);
          $db_port = $port[1];
          $db_name = 'stage';
          break;

        default:
          $db_port = '3306';
          $db_name = 'dev_db';
      }
    }

    var_dump(LOCALHOST);
    var_dump(DEV_MYSQL_PASS);
    var_dump($db_name);
    var_dump($db_port);

    while (!@mysqli_connect(LOCALHOST, 'dev', DEV_MYSQL_PASS, $db_name, $db_port)) {
      sleep(1);
      echo '.';
    }

    $io->text(' ');
    $io->success('mySQL CONNECTED');
  }
}<commit_msg>remove sleep vulnerability and nicer UX wait for user<commit_after><?php

/**
 * @file
 * Contains \Docker\Drupal\Extension\DemoCommand.
 */

namespace Docker\Drupal\Extension;

use Docker\Drupal\Application;

const DEV_MYSQL_PASS = '<PASSWORD>';
const LOCALHOST = '127.0.0.1';

/**
 * Class ApplicationConfigExtension
 * @package Docker\Drupal\Extension
 */
class ApplicationConfigExtension extends Application {

  /**
   * Verify mySQL container is ready.
   *
   * @param $io
   * @param $system_appname
   * @param $type
   */
  function verifyMySQL($io, $system_appname, $type) {
    // Check for running mySQL container before launching Drupal Installation.
    $io->text(' ');
    $io->warning('Waiting for mySQL service.');

    if ($type) {
      switch ($type) {
        case 'prod':
          $command = exec('docker port mysql 3306');
          $port = explode(':', $command);
          $db_port = $port[1];
          $db_name = 'prod';
          break;

        case 'stage':
          $command = "docker-compose -f docker_" . $system_appname . "/docker-compose-data.yml --project-name=" . $system_appname . "_data port db 3306";
          $port_info = exec($command);
          $port = explode(':', $port_info);
          $db_port = $port[1];
          $db_name = 'stage';
          break;

        default:
          $db_port = '3306';
          $db_name = 'dev_db';
      }
    }

    while (!@mysqli_connect(LOCALHOST, 'dev', DEV_MYSQL_PASS, $db_name, $db_port)) {
      $phases = array("|", "/", "-", "\\");
      foreach ($phases AS $phase)
      {
        printf('%s%s', chr(8), $phase);
        usleep(100000); // Replace this with one iteration of doing stuff
      }
    }

    $io->text(' ');
    $io->success('mySQL CONNECTED');
  }
}
{'fraction_non_alphanumeric': 0.15757042253521128, 'fraction_numerical': 0.014084507042253521, 'mean_word_length': 2.4399596367305754, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6637028', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1113, 'n_words': 248}