Tencent / Tencent/Biny

反馈一个路由配置相关的Bug

Open
#140 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.7k
Forks
253
PR merge metrics
No merged PRs in 30d

Description

比如说,
我先定义了这样的路由①:

// 用户个人中心
'u/<id:\d+>' => 'space/index',
'u' => 'space/index',

然后有另外一个路由②:

'<path:\w+>' => 'mod/game',

这两个路由都是在 config\config.php文件里面的 routeRule数组里面配置的

然后,如果我访问的是 "http://localhost/taiwu",
正常我是希望他走路由②,但实际上他会这样一个错误:

Fatal error:  Autoload file[taiwspaceAction] is fails in /home/wwwroot/mod/lib/Autoload.php:124
Stack trace:
#0 [internal function]: biny\lib\Autoload::load('taiwspaceAction')
#1 /home/wwwroot/mod/lib/business/Factory.php(68): spl_autoload_call('taiwspaceAction')
#2 /home/wwwroot/mod/lib/business/Factory.php(45): biny\lib\Factory::loadClass('taiwspaceAction', 'taiwspaceAction')
#3 /home/wwwroot/mod/lib/business/Request.php(255): biny\lib\Factory::create('taiwspaceAction')
#4 /home/wwwroot/mod/lib/business/Controller.php(54): biny\lib\Request->getModule(true)
#5 /home/wwwroot/mod/lib/business/Controller.php(42): biny\lib\Controller->call(Object(biny\lib\Request))
#6 /home/wwwroot/mod/lib/business/Controller.php(105): biny\lib\Controller->execute()
#7 /home/wwwroot/mod/lib/App.php(176): biny\lib\Controller->dispatcher()
#8 /home/wwwroot/mod/web/index.php(21): App::run()
#9 {main}

他把taiwu后面的u替换成了space,然后再去找 taiwspaceAction ,发现没找到,结果返回404.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the request for /taiwu with the routeRule entries in config/config.php, then trace route handling through lib/business/Request.php and the Factory/Controller stack frames shown in the report. The fix is done when /taiwu selects the path:\w+ route instead of substituting u with space, and the request no longer produces the autoload failure or 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.