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

Tool cleanup_mri_tables_for_19-0_release.php prompting for MySQL username and password #3473

Merged
Changes from all 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
24 changes: 17 additions & 7 deletions tools/cleanup_mri_tables_for_19-0_release.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,25 @@ function backupEntries($selectID, $table_name, $FK_field)
$config->load(__DIR__."/../project/config.xml");
$database = $config->getSettingFromXML("database");

// prompt for mysql username
$prompt = "Enter MySQL username with mysqldump permission:";
$username = readline($prompt);

// prompt for mysql password
echo "Enter password:";
system('/bin/stty -echo');
$password = trim(fgets(STDIN));
system("/bin/stty echo");

// create the mysqldump query to back the orphan entries to be deleted
$sqldump = "mysqldump " .
"-u " . escapeshellarg($database['username']) . " " .
"-h " . escapeshellarg($database['host']) . " " .
"-p" . escapeshellarg($database['password']) . " " .
escapeshellarg($database['database']) . " " .
escapeshellarg($table_name) . " " .
"--where=" . escapeshellarg($where) . " " .
"--compact --no-create-info" . " " .
"-u " . escapeshellarg($username) . " " .
"-h " . escapeshellarg($database['host']) . " " .
"-p" . escapeshellarg($password) . " " .
escapeshellarg($database['database']) . " " .
escapeshellarg($table_name) . " " .
"--where=" . escapeshellarg($where) . " " .
"--compact --no-create-info" . " " .
">> ./backup_release_19-0_upgrade.sql";

system($sqldump, $retval); // execute mysqldump
Expand Down