| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | public function update(Connection $connection): void |
||
| 16 | { |
||
| 17 | // get all themes where preview_media_id is invalid |
||
| 18 | $themeIdsWithInvalidMediaId = $connection->executeQuery(' |
||
| 19 | SELECT `theme`.`id` FROM `theme` |
||
| 20 | LEFT OUTER JOIN `media` ON `theme`.`preview_media_id` = `media`.`id` |
||
| 21 | WHERE `media`.`id` IS null |
||
| 22 | ')->fetchColumn(); |
||
| 23 | |||
| 24 | $connection->executeUpdate(' |
||
| 25 | UPDATE `theme` SET `theme`.`preview_media_id` = null |
||
| 26 | WHERE `theme`.`id` IN (:theme_ids) |
||
| 27 | ', ['theme_ids' => $themeIdsWithInvalidMediaId]); |
||
| 28 | |||
| 29 | $connection->exec(' |
||
| 30 | ALTER TABLE `theme` |
||
| 42 |