| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Version20250624012300 extends AbstractMigrationChamilo |
||
| 13 | { |
||
| 14 | public function getDescription(): string |
||
| 17 | } |
||
| 18 | |||
| 19 | public function up(Schema $schema): void |
||
| 20 | { |
||
| 21 | // Retrieve all language entries where original_name contains HTML entities |
||
| 22 | $languages = $this->connection->fetchAllAssociative( |
||
| 23 | "SELECT id, original_name FROM language WHERE original_name LIKE '%&%;%'" |
||
| 24 | ); |
||
| 25 | |||
| 26 | foreach ($languages as $lang) { |
||
| 27 | $decoded = html_entity_decode((string) $lang['original_name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); |
||
| 28 | |||
| 29 | // Only update if the decoded value is different |
||
| 30 | if ($decoded !== $lang['original_name']) { |
||
| 31 | $this->addSql( |
||
| 32 | "UPDATE language SET original_name = :decoded WHERE id = :id", |
||
| 33 | [ |
||
| 34 | 'decoded' => $decoded, |
||
| 35 | 'id' => $lang['id'], |
||
| 36 | ] |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | public function down(Schema $schema): void |
||
| 44 | // This migration is not reversible, as the original entity-encoded values are lost |
||
| 45 | } |
||
| 47 |