Fix #18493: Faster request parsing for REST UrlRule with prefix handling

This commit is contained in:
Bizley
2021-01-26 13:49:14 +01:00
committed by GitHub
parent 03befccd48
commit bb1489dab1
3 changed files with 7 additions and 0 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 #18493: Faster request parsing for REST UrlRule with prefix handling (bizley)
- Enh #18487: Allow creating URLs for non-GET-verb rules (bizley)

View File

@ -216,6 +216,10 @@ class UrlRule extends CompositeUrlRule
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
if ($this->prefix !== '' && strpos($pathInfo . '/', $this->prefix . '/') !== 0) {
return false;
}
foreach ($this->rules as $urlName => $rules) {
if (strpos($pathInfo, $urlName) !== false) {
foreach ($rules as $rule) {