Fix #18487: Allow creating URLs for non-GET-verb rules

This commit is contained in:
Bizley
2021-01-26 12:47:53 +01:00
committed by GitHub
parent be6fa87642
commit 03befccd48
6 changed files with 29 additions and 15 deletions

View File

@ -14,6 +14,7 @@ Yii Framework 2 Change Log
- Bug #18479: Fix invalid argument type for `preg_split` in `\yii\console\Controller` (gazooz)
- Bug #18477: Fix detecting availability of Xdebug's stack trace in `yii\base\ErrorException` (bizley)
- Bug #18480: Transactions are not committed using the dblib driver (bbrunekreeft)
- Enh #18487: Allow creating URLs for non-GET-verb rules (bizley)
2.0.40 December 23, 2020

View File

@ -205,9 +205,6 @@ class UrlRule extends CompositeUrlRule
$config['verb'] = $verbs;
$config['pattern'] = rtrim($prefix . '/' . strtr($pattern, $this->tokens), '/');
$config['route'] = $action;
if (!empty($verbs) && !in_array('GET', $verbs)) {
$config['mode'] = WebUrlRule::PARSING_ONLY;
}
$config['suffix'] = $this->suffix;
return Yii::createObject($config);

View File

@ -245,10 +245,6 @@ class UrlManager extends Component
$rule = ['route' => $rule];
if (preg_match("/^((?:($verbs),)*($verbs))\\s+(.*)$/", $key, $matches)) {
$rule['verb'] = explode(',', $matches[1]);
// rules that are not applicable for GET requests should not be used to create URLs
if (!in_array('GET', $rule['verb'], true)) {
$rule['mode'] = UrlRule::PARSING_ONLY;
}
$key = $matches[4];
}
$rule['pattern'] = $key;