File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
src/CoreBundle/Migrations/Schema/V200 Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /* For licensing terms, see /license.txt */
4
+
5
+ declare (strict_types=1 );
6
+
7
+ namespace Chamilo \CoreBundle \Migrations \Schema \V200 ;
8
+
9
+ use Chamilo \CoreBundle \Migrations \AbstractMigrationChamilo ;
10
+ use Doctrine \DBAL \Schema \Schema ;
11
+
12
+ class Version20250624012300 extends AbstractMigrationChamilo
13
+ {
14
+ public function getDescription (): string
15
+ {
16
+ return 'Decode HTML entities in language.original_name to UTF-8 ' ;
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
43
+ {
44
+ // This migration is not reversible, as the original entity-encoded values are lost
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments