top-think / top-think/think-orm
db before_select 事件的重大bug,无解不能执行下去
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
before_select事件返回的一定是数组,因为Event类的diaptch,没有加once参数,方法返回的一定是数组. 而执行事件使用的是
if (!$resultSet)
判断结果一定是false,导致真正的查询没有调用
`$resultSet = $this->db->trigger('before_select', $query);
if (!$resultSet) {
// 执行查询操作
$resultSet = $this->pdoQuery($query, function ($query) {
return $this->builder->select($query);
});
}`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the before_select trigger shown in the issue and trace Event::dispatch, then follow the database query path through db->trigger and pdoQuery. Verify how the event result is represented and when the fallback query runs. Done means a before_select event that does not provide a usable result no longer prevents the real select query from executing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100