top-think / top-think/think-orm
getChangedData() 获取变化的数据 方法错误
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
对于下面这段代码,对比$data和$origin,这两个应当是不一样的,但是原有代码认为这两个数据没有变换,
原因是return is_object($a) || $a != $b ? 1 : 0;,
这里的比较应该用强等于,
$data = [
'date'=>'2019'
];
$origin = [
'date'=>'2019.'
];
$result = array_udiff_assoc($data, $origin, function ($a, $b) {
if ((empty($a) || empty($b)) && $a !== $b) {
return 1;
}
return is_object($a) || $a != $b ? 1 : 0;
// return is_object($a) || $a !== $b ? 1 : 0; // 这样就生效了
});
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
Locate the getChangedData() implementation and reproduce the issue with the provided $data and $origin arrays. Verify the comparison distinguishes '2019' from '2019.' and add or update a regression test if the project’s existing tests cover this method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100