aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2025-02-25 04:38:08 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2025-02-25 04:38:08 +0000
commitbb374471aa930ffbe4614fafe4faf5caeac03c43 (patch)
treef393d91b1bfddec1b2d80e1345588fb854316118 /maintenance
parent33d4b9e7644807d8df52c13542ed33e3efbb4c21 (diff)
parent8931b40119ebd2f9794973483f31b8f4fe95560c (diff)
downloadmediawikicore-bb374471aa930ffbe4614fafe4faf5caeac03c43.tar.gz
mediawikicore-bb374471aa930ffbe4614fafe4faf5caeac03c43.zip
Merge "Add Y/n prompt at the end of interactive install"
Diffstat (limited to 'maintenance')
-rw-r--r--maintenance/includes/Maintenance.php21
-rw-r--r--maintenance/install.php4
2 files changed, 25 insertions, 0 deletions
diff --git a/maintenance/includes/Maintenance.php b/maintenance/includes/Maintenance.php
index cf895640fe6a..a51f653237bf 100644
--- a/maintenance/includes/Maintenance.php
+++ b/maintenance/includes/Maintenance.php
@@ -1653,6 +1653,27 @@ abstract class Maintenance {
return $line;
}
+
+ /**
+ * @param string $prompt The prompt to display to the user
+ * @param bool|null $default The default value to return if the user just presses enter
+ *
+ * @return ?bool
+ *
+ * @since 1.44
+ */
+ protected function promptYesNo( $prompt, $default = null ) {
+ $defaultText = $default === null ? '' : ( $default ? 'Y' : 'n' );
+ $line = self::readconsole( $prompt . " (Y/n) [$defaultText]" );
+ if ( $line === false ) {
+ return $default;
+ }
+ if ( $line === '' ) {
+ return $default;
+ }
+
+ return strtolower( $line ) === 'y';
+ }
}
/** @deprecated class alias since 1.43 */
diff --git a/maintenance/install.php b/maintenance/install.php
index 9a3cfdc2f7c6..2a4234e96167 100644
--- a/maintenance/install.php
+++ b/maintenance/install.php
@@ -182,6 +182,10 @@ class CommandLineInstaller extends Maintenance {
$this->setOption( 'dbuser', $dbUser );
$this->setOption( 'dbpass', $dbPass );
$this->setOption( 'dbserver', $dbServer );
+ if ( !$this->promptYesNo( 'Do you want to continue with the installation?', true ) ) {
+ $this->output( "Installation aborted.\n" );
+ return false;
+ }
}
$siteName = $this->getArg( 0, 'MediaWiki' ); // Will not be set if used with --env-checks