Commit c997e0d0 by Thiago Talma Committed by Alexander Makarov

Fixes #7094: Console confirmation must be answered correctly. To return `true`:…

Fixes #7094: Console confirmation must be answered correctly. To return `true`: `y` or `yes`. To return `false`: `n` or `not`. Any other input the question will be asked again
parent 75dd45a8
......@@ -19,6 +19,7 @@ Yii Framework 2 Change Log
- Enh #7051: Added support for preventing swapping values between different cookies (pavimus, qiangxue)
- Chg #5690: adjusted paths in message config generated by `yii message/config` to reflect directory structure better (mikehaertl, samdark)
- Chg #6661: Hyperlinks that are enclosed within an exist form will use the same form for submission if they specify both of the `href` and `data-method` attributes (qiangxue)
- Chg #7094: Console confirmation must be answered correctly. To return `true`: `y` or `yes`. To return `false`: `n` or `not`. Any other input the question will be asked again (thiagotalma)
2.0.2 January 11, 2015
----------------------
......
......@@ -769,10 +769,22 @@ class BaseConsole
*/
public static function confirm($message, $default = false)
{
while (true) {
static::stdout($message . ' (yes|no) [' . ($default ? 'yes' : 'no') . ']:');
$input = trim(static::stdin());
return empty($input) ? $default : !strncasecmp($input, 'y', 1);
if (empty($input)) {
return $default;
}
if (!strcasecmp ($input, 'y') || !strcasecmp ($input, 'yes') ) {
return true;
}
if (!strcasecmp ($input, 'n') || !strcasecmp ($input, 'no') ) {
return false;
}
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment