From f62a68f322175e45644f1cdcb8900a079df61ba3 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 6 Mar 2012 22:33:45 +0400 Subject: [PATCH 1/7] Added default value support for \yii\console\Command::prompt --- framework/console/Command.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/framework/console/Command.php b/framework/console/Command.php index 6f30231..a3c41bc 100644 --- a/framework/console/Command.php +++ b/framework/console/Command.php @@ -304,19 +304,36 @@ abstract class Command extends \yii\base\Component * Reads input via the readline PHP extension if that's available, or fgets() if readline is not installed. * * @param string $message to echo out before waiting for user input + * @param string $default the default string to be returned when user does not write anything. Defaults to null. * @return mixed line read as a string, or false if input has been closed */ - public function prompt($message) + public function prompt($message, $default = null) { + if($default !== null) { + $message .= " [$default] "; + } + else { + $message .= ' '; + } + if(extension_loaded('readline')) { - $input = readline($message.' '); - readline_add_history($input); - return $input; - } else - { - echo $message.' '; - return trim(fgets(STDIN)); + $input = readline($message); + if($input) { + readline_add_history($input); + } + } else { + echo $message; + $input = fgets(STDIN); + if($input === false) { + $input = trim($input); + } + } + if($input === false) { + return false; + } + else { + return empty($input) ? $default : $input; } } From 4509d9da3e528c16f28b935905589c2cf4aea7dd Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 6 Mar 2012 23:29:59 +0400 Subject: [PATCH 2/7] more todo items --- todo.md | 7 +++++-- upgrade.md | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/todo.md b/todo.md index 867d287..2aa3638 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,7 @@ * CompareValidator::clientValidateAttribute(): search for "CHtml::activeId" * FileValidator, UniqueValidator, ExistValidator, DateValidator: TBD * consider merging UniqueValidator and ExistValidator and using a NOT property. -- console command support +- console command support [DONE] - built-in console commands + api doc builder * support for markdown syntax @@ -59,5 +59,8 @@ * ability to manage scripts order (store these in a vector?) * http://ryanbigg.com/guides/asset_pipeline.html, http://guides.rubyonrails.org/asset_pipeline.html, use content hash instead of mtime + directory hash. - Requirement checker +- Optional configurable input filtering in request - widgets - * if we're going to supply default ones, these should generate really unique IDs. This will solve a lot of AJAX-nesting problems. \ No newline at end of file + * if we're going to supply default ones, these should generate really unique IDs. This will solve a lot of AJAX-nesting problems. +- Make sure type hinting is used when components are passed to methods +- Decouple controller from application (by passing web application instance to controller and if not passed, using Yii::app())? \ No newline at end of file diff --git a/upgrade.md b/upgrade.md index 803be7c..42faf82 100644 --- a/upgrade.md +++ b/upgrade.md @@ -10,14 +10,14 @@ for both A and B. General upgrade instructions ---------------------------- +---------------------------- - Make a backup. - Clean up your 'assets' folder. -- Replace 'framework' dir with the new one or point SVN to a fresh - release and update. -- Check if everything is OK, if not — revert from backup and post - issues to Yii issue tracker. +- Replace 'framework' dir with the new one or point Git to a fresh + release tag and checkout. +- Check if everything is OK, if not — revert to previous stable version and post + issues to [Yii issue tracker](https://github.com/yiisoft/yii/issues). Upgrading from v1.1.x From 59977e341ab69cebb16dcc389c41baa274ef228b Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 Mar 2012 00:42:22 +0400 Subject: [PATCH 3/7] and some more todos --- todo.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/todo.md b/todo.md index 2aa3638..13ced6a 100644 --- a/todo.md +++ b/todo.md @@ -1,11 +1,11 @@ - logging * WebTarget * ProfileTarget - * Toolbar ? - base * error/exception handling * Convert all PHP errors into exceptions, remove YII_ENABLE_ERROR_HANDLER and error handler (?) * module + - Module should be able to define its own configuration including routes. Application should be able to overwrite it. * application * http exception * security @@ -49,6 +49,7 @@ - web: TBD * get/setFlash() should be moved to session component * support optional parameter in URL patterns + * Response object. - gii * move generation API out of gii, provide yiic commands to use it. Use same templates for gii/yiic. * i18n variant of templates @@ -63,4 +64,5 @@ - widgets * if we're going to supply default ones, these should generate really unique IDs. This will solve a lot of AJAX-nesting problems. - Make sure type hinting is used when components are passed to methods -- Decouple controller from application (by passing web application instance to controller and if not passed, using Yii::app())? \ No newline at end of file +- Decouple controller from application (by passing web application instance to controller and if not passed, using Yii::app())? +- Decouple view renderer from controller so it can be used separately (useful for sending emails from console etc.) \ No newline at end of file From b1f9bf5b55869f1de34ac5feee0dffae25b2326e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 Mar 2012 01:14:04 +0400 Subject: [PATCH 4/7] fixed wrong condition --- framework/console/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/Command.php b/framework/console/Command.php index a3c41bc..16ba810 100644 --- a/framework/console/Command.php +++ b/framework/console/Command.php @@ -325,7 +325,7 @@ abstract class Command extends \yii\base\Component } else { echo $message; $input = fgets(STDIN); - if($input === false) { + if($input !== false) { $input = trim($input); } } From 434d31ddb413a3738d43c4a4b59a9ccdd01b719f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 Mar 2012 02:37:06 +0400 Subject: [PATCH 5/7] better code for prompt --- framework/console/Command.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/framework/console/Command.php b/framework/console/Command.php index 16ba810..eef9035 100644 --- a/framework/console/Command.php +++ b/framework/console/Command.php @@ -325,15 +325,13 @@ abstract class Command extends \yii\base\Component } else { echo $message; $input = fgets(STDIN); - if($input !== false) { - $input = trim($input); - } } if($input === false) { return false; } else { - return empty($input) ? $default : $input; + $input = trim($input); + return $input==='' ? $default : $input; } } From dd091c2ff3204e8ea742dbb9a066172e6edf04a8 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 Mar 2012 03:46:28 +0400 Subject: [PATCH 6/7] added check for default value --- framework/console/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/Command.php b/framework/console/Command.php index eef9035..9c6eb5d 100644 --- a/framework/console/Command.php +++ b/framework/console/Command.php @@ -331,7 +331,7 @@ abstract class Command extends \yii\base\Component } else { $input = trim($input); - return $input==='' ? $default : $input; + return ($input==='' && $default!==null) ? $default : $input; } } From f6a6c2cedf916508301dda4c8891c5c270217050 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 Mar 2012 14:09:00 +0400 Subject: [PATCH 7/7] updated default description --- framework/console/Command.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/console/Command.php b/framework/console/Command.php index 9c6eb5d..e2ca243 100644 --- a/framework/console/Command.php +++ b/framework/console/Command.php @@ -304,7 +304,8 @@ abstract class Command extends \yii\base\Component * Reads input via the readline PHP extension if that's available, or fgets() if readline is not installed. * * @param string $message to echo out before waiting for user input - * @param string $default the default string to be returned when user does not write anything. Defaults to null. + * @param string $default the default string to be returned when user does not write anything. + * Defaults to null, means that default string is disabled. * @return mixed line read as a string, or false if input has been closed */ public function prompt($message, $default = null)