mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fix #18493: Faster request parsing for REST UrlRule with prefix handling
This commit is contained in:
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -86,6 +86,8 @@ class UrlRuleTest extends TestCase
|
||||
['controller' => 'post', 'prefix' => 'admin'],
|
||||
[
|
||||
['admin/posts', 'post/index'],
|
||||
['different/posts', false],
|
||||
['posts', false],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user