yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework

Home Page:http://www.yiiframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to resolve the request "--" with chroot

gozoro opened this issue · comments

What steps will reproduce the problem?

When php is launched with chroot as:

sudo /usr/sbin/chroot /opt/php55 /usr/bin/php "$@"

and in bash, run the command:

./yii

Method \yii\console\Request::resolve() throws exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "--".'

What is the expected result?

I expected the route to resolve as "help".

What do you get instead?

This happens because $_SERVER['argv'] contains an array:

Array
(
    [0] => /var/www/my_project/yii
    [1] => --
)

and route resolved as NULL.

Additional info

Q A
Yii version 2.0.49
PHP version 5.5
Operating system Ubuntu 18.04

Fix.
Change this line

$route = array_shift($rawParams);

to

$route = (string)array_shift($rawParams);