{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/7894","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/7894/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/7894/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/7894/events","html_url":"https://github.com/yiisoft/yii2/issues/7894","id":64748189,"number":7894,"title":"array_splice to get an url's parameters is wrong","user":{"login":"nkovacs","id":2269242,"avatar_url":"https://avatars.githubusercontent.com/u/2269242?v=3","gravatar_id":"","url":"https://api.github.com/users/nkovacs","html_url":"https://github.com/nkovacs","followers_url":"https://api.github.com/users/nkovacs/followers","following_url":"https://api.github.com/users/nkovacs/following{/other_user}","gists_url":"https://api.github.com/users/nkovacs/gists{/gist_id}","starred_url":"https://api.github.com/users/nkovacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkovacs/subscriptions","organizations_url":"https://api.github.com/users/nkovacs/orgs","repos_url":"https://api.github.com/users/nkovacs/repos","events_url":"https://api.github.com/users/nkovacs/events{/privacy}","received_events_url":"https://api.github.com/users/nkovacs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-27T12:03:13Z","updated_at":"2015-03-27T12:45:18Z","closed_at":null,"body":"If you have a url that is an array, and you add the route later, even though the route will be `$url[0]`, its offset won't be 0, so using `array_splice($url, 1)` to get the parameters is wrong.\r\n\r\nFor example:\r\n\r\n```php\r\n$url = ['param1' => 'foo', 'param2' => 'bar'];\r\n$url[] = 'controller/action';\r\n\r\n$params = array_splice($url, 1); // will be ['param2' => 'bar', 0 => 'controller/action']\r\n```\r\n\r\n* https://github.com/yiisoft/yii2/blob/bbbeae95a15f6299dae202f2c64367b49ee0400f/framework/web/Application.php#L78\r\n* https://github.com/yiisoft/yii2/blob/81bcd116a83dc24c9db2d8cd73f65074e09863bf/framework/widgets/Menu.php#L318\r\n* https://github.com/yiisoft/yii2-bootstrap/blob/84ad12bc5c409d62db1cef6e25023beccf3b8f1a/Nav.php#L244\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/86930203","html_url":"https://github.com/yiisoft/yii2/issues/7894#issuecomment-86930203","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/7894","id":86930203,"user":{"login":"nkovacs","id":2269242,"avatar_url":"https://avatars.githubusercontent.com/u/2269242?v=3","gravatar_id":"","url":"https://api.github.com/users/nkovacs","html_url":"https://github.com/nkovacs","followers_url":"https://api.github.com/users/nkovacs/followers","following_url":"https://api.github.com/users/nkovacs/following{/other_user}","gists_url":"https://api.github.com/users/nkovacs/gists{/gist_id}","starred_url":"https://api.github.com/users/nkovacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkovacs/subscriptions","organizations_url":"https://api.github.com/users/nkovacs/orgs","repos_url":"https://api.github.com/users/nkovacs/repos","events_url":"https://api.github.com/users/nkovacs/events{/privacy}","received_events_url":"https://api.github.com/users/nkovacs/received_events","type":"User","site_admin":false},"created_at":"2015-03-27T12:45:18Z","updated_at":"2015-03-27T12:45:18Z","body":"I haven't run into this, so I can only come up with contrived examples. But that doesn't change the fact that it's wrong.\r\n\r\n```php\r\n// in controller\r\n$url = array_intersect_key($_GET, array_flip($allowedParams));\r\n$url[] = 'some-action';\r\n\r\n// then use $url in menu or nav\r\n```\r\n\r\nor this, though it's unlikely someone would write the url like this:\r\n\r\n```php\r\n'catchAll' => ['reason' => 'maintenance', 'site/offline'],\r\n```"}}