| Conditions | 8 |
| Paths | 26 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | private function migrate($query, \Closure $existCallback, \Closure $callback, $userTransaction = true): array |
||
| 29 | { |
||
| 30 | $transaction = $userTransaction ? \Yii::$app->db->beginTransaction() : null; |
||
| 31 | $count = $query->count(); |
||
| 32 | try { |
||
| 33 | for ($i = 0; $i <= (int)ceil($count / $this->onceCount); $i++) { |
||
| 34 | $items = $query |
||
| 35 | ->orderBy(['id' => SORT_ASC]) |
||
| 36 | ->limit($this->onceCount) |
||
| 37 | ->offset($i * $this->onceCount) |
||
| 38 | ->all(); |
||
| 39 | // item is array |
||
| 40 | foreach ($items as $item) { |
||
| 41 | if (!call_user_func($existCallback, $item)) { |
||
| 42 | // todo batch insert |
||
| 43 | $ids[] = call_user_func($callback, $item); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | $userTransaction ? $transaction->commit() : null; |
||
|
|
|||
| 48 | sleep($this->sleepSecond); |
||
| 49 | return $ids ?? []; |
||
| 50 | } catch (\Exception $e) { |
||
| 51 | $userTransaction ? $transaction->rollBack() : null; |
||
| 52 | \Yii::error('修复数据失败', ['query' => $query, (string)$e]); |
||
| 53 | throw $e; |
||
| 54 | } |
||
| 57 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.