Skip to content

Bug: CLI command can't get param data properly #5266

@kenjis

Description

@kenjis

Describe the bug

  • When controllers run via CLI, they can't get param data properly
  • CLI commands can't get param data properly

e.g.

  • input abc < def → param abc
  • input McDonald's → param McDonald&#39;s
  • input <s>aaa</s> → param aaa

Related #5263

CodeIgniter 4 version
develop after 4.1.4

Affected module(s)
CLIRequest

Expected behavior, and steps to reproduce if appropriate

Controller

<?php
namespace App\Controllers;
use CodeIgniter\Controller;
class Test extends Controller
{
    public function run($param = '')
    {
        var_dump($param);
    }
}
$ php public/index.php test run 'abc < def'
string(4) "abc "
$ php public/index.php test run "McDonald's"
string(14) "McDonald&#39;s"
$ php public/index.php test run '<s>aaa</s>'
string(3) "aaa"

Command

<?php
namespace App\Commands;
use CodeIgniter\CLI\BaseCommand;
class Test extends BaseCommand
{
    protected $group       = 'tests';
    protected $name        = 'test';
    protected $description = 'Just testing.';

    public function run(array $params)
    {
        var_dump($params);
    }
}
$ php spark test 'abc < def'

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:20 UTC-05:00

array(1) {
  [0] =>
  string(4) "abc "
}
$ php spark test "McDonald's"

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:30 UTC-05:00

array(1) {
  [0] =>
  string(14) "McDonald&#39;s"
}
$ php spark test '<s>aaa</s>'

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:39 UTC-05:00

array(1) {
  [0] =>
  string(3) "aaa"
}

Context

  • OS: [macOS 10.15.7]
  • Web server [n/a]
  • PHP version [8.0.12]
  • Database: [n/a]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions