| Conditions | 3 |
| Paths | 3 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | public function start(): bool |
||
| 41 | { |
||
| 42 | $cursor = $this->db->{'fs.files'}->find([ |
||
| 43 | 'metadata.ref' => ['$exists' => 1], |
||
| 44 | ]); |
||
| 45 | |||
| 46 | foreach ($cursor as $object) { |
||
| 47 | $references = []; |
||
| 48 | foreach ($object['metadata']['ref'] as $reference) { |
||
| 49 | $references[] = $reference['id']; |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->db->storage->updateOne( |
||
| 53 | ['_id' => $object['_id']], |
||
| 54 | [ |
||
| 55 | '$unset' => [ |
||
| 56 | 'metadata.ref' => 1, |
||
| 57 | 'metadata.share_ref' => 1, |
||
| 58 | ], |
||
| 59 | '$set' => [ |
||
| 60 | 'metadata.references' => $references, |
||
| 61 | ], |
||
| 62 | ] |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | |||
| 66 | return true; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |