| Conditions | 3 |
| Paths | 2 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function start(): bool |
||
| 37 | { |
||
| 38 | $cursor = $this->db->storage->aggregate([ |
||
| 39 | ['$unwind' => '$history'], |
||
| 40 | ['$match' => [ |
||
| 41 | 'history.storage' => ['$exists' => 0], |
||
| 42 | ]], |
||
| 43 | ]); |
||
| 44 | |||
| 45 | foreach ($cursor as $object) { |
||
| 46 | $this->db->storage->updateOne( |
||
| 47 | [ |
||
| 48 | '_id' => $object['_id'], |
||
| 49 | 'history.version' => $object['history']['version'], |
||
| 50 | ], |
||
| 51 | [ |
||
| 52 | '$set' => [ |
||
| 53 | 'history.$.storage' => $object['history']['file'] === null ? null : ['_id' => $object['history']['file']], |
||
| 54 | 'history.$.storage_adapter' => 'gridfs', |
||
| 55 | ], |
||
| 56 | '$unset' => ['history.$.file' => true] |
||
| 57 | ] |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | return true; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |