Skip to content

Commit

Permalink
Fixes yiisoft#14355: Added ability to pass an empty array as a parame…
Browse files Browse the repository at this point in the history
…ter in console command
  • Loading branch information
developeruz authored and samdark committed Jan 9, 2018
1 parent a559b9f commit af83e59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Yii Framework 2 Change Log
- Enh #9253: Allow `variations` to be a string for `yii\filters\PageCache` and `yii\widgets\FragmentCache` (schojniak, developeruz)
- Enh #12623: Added `yii\helpers\StringHelper::matchWildcard()` replacing usage of `fnmatch()`, which may be unreliable (klimov-paul)
- Enh #14043: Added `yii\helpers\IpHelper` (silverfire, cebe)
- Enh #14355: Added ability to pass an empty array as a parameter in console command (developeruz)
- Enh #14568: Refactored migration templates to use `safeUp()` and `safeDown()` methods (Kolyunya)
- Enh #14662: Added support for custom `Content-Type` specification to `yii\web\JsonResponseFormatter` (Kolyunya)
- Enh #15024: `yii\web\Pjax` widget does not prevent CSS files from sending anymore because they are handled by client-side plugin correctly (onmotion)
Expand Down
2 changes: 1 addition & 1 deletion framework/console/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function bindActionParams($action, $params)
$missing = [];
foreach ($method->getParameters() as $i => $param) {
if ($param->isArray() && isset($args[$i])) {
$args[$i] = preg_split('/\s*,\s*/', $args[$i]);
$args[$i] = $args[$i] === '' ? [] : preg_split('/\s*,\s*/', $args[$i]);
}
if (!isset($args[$i])) {
if ($param->isDefaultValueAvailable()) {
Expand Down
4 changes: 4 additions & 0 deletions tests/framework/console/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function testBindActionParams()
$result = $controller->runAction('aksi2', $params);
$this->assertEquals([['d426', 'mdmunir'], 'single'], $result);

$params = ['', 'single'];
$result = $controller->runAction('aksi2', $params);
$this->assertEquals([[], 'single'], $result);

$params = ['_aliases' => ['t' => 'test']];
$result = $controller->runAction('aksi4', $params);
$this->assertEquals('test', $result);
Expand Down

0 comments on commit af83e59

Please sign in to comment.