yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Unable to resolve the request "--" with chroot #20159

Open gozoro opened 4 months ago

gozoro commented 4 months ago

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
gozoro commented 4 months ago

Fix. Change this line https://github.com/yiisoft/yii2/blob/f2ea9be24225987b2acf2d6fdd2789e0a32b7fb0/framework/console/Request.php#L68 to

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