@@ -381,12 +381,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
381
381
382
382
$ lastItem = count ($ versionsToRun );
383
383
$ counter = 0 ;
384
- $ runFixIds = false ;
384
+
385
385
foreach ($ versionsToRun as $ versionItem => $ versionInfo ) {
386
- if ($ lastItem == $ counter ) {
386
+ $ runFixIds = false ;
387
+ $ runLpFix = false ;
388
+ if ($ versionItem === '1.10.0 ' ) {
387
389
$ runFixIds = true ;
388
390
}
389
391
392
+ if ($ versionItem === '1.11.0 ' ) {
393
+ $ runLpFix = true ;
394
+ }
395
+
390
396
if (isset ($ versionInfo ['require_update ' ]) &&
391
397
$ versionInfo ['require_update ' ] == true
392
398
) {
@@ -404,12 +410,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
404
410
$ removeUnusedTables ,
405
411
$ input ,
406
412
$ runFixIds ,
407
- $ onlyUpdateDatabase
413
+ $ onlyUpdateDatabase ,
414
+ $ runLpFix
408
415
);
409
-
410
- $ currentVersion = $ versionItem ;
411
- $ output ->writeln ("<comment>End database migration</comment> " );
416
+ $ output -> writeln ( " <comment>Run fixes value: $ runFixIds </comment> " );
417
+ $ output -> writeln ( " <comment>End database migration of version: $ currentVersion </comment> " ) ;
418
+ $ output ->writeln ("---------------------------------------------------------------- " );
412
419
$ output ->writeln ("---------------------------------------------------------------- " );
420
+ $ currentVersion = $ versionItem ;
413
421
} else {
414
422
$ currentVersion = $ versionItem ;
415
423
$ output ->writeln ("<comment>Skip migration from version: </comment><info> $ currentVersion</info><comment> to version </comment><info> $ versionItem " );
@@ -486,15 +494,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
486
494
/**
487
495
* Starts a migration
488
496
*
489
- * @param array $courseList
490
- * @param string $path
491
- * @param string $toVersion
492
- * @param bool $dryRun
497
+ * @param array $courseList
498
+ * @param string $path
499
+ * @param string $toVersion
500
+ * @param bool $dryRun
493
501
* @param OutputInterface $output
494
- * @param bool $removeUnusedTables
495
- * @param InputInterface $mainInput
496
- * @param bool $runFixIds
497
- * @param bool $onlyUpdateDatabase
502
+ * @param bool $removeUnusedTables
503
+ * @param InputInterface $mainInput
504
+ * @param bool $runFixIds
505
+ * @param bool $onlyUpdateDatabase
506
+ * @param bool $runLpFix
498
507
*
499
508
* @return bool
500
509
* @throws \Exception
@@ -508,7 +517,8 @@ public function startMigration(
508
517
$ removeUnusedTables = false ,
509
518
InputInterface $ mainInput ,
510
519
$ runFixIds = true ,
511
- $ onlyUpdateDatabase = false
520
+ $ onlyUpdateDatabase = false ,
521
+ $ runLpFix = false
512
522
) {
513
523
// Cleaning query list.
514
524
$ this ->queryList = array ();
@@ -614,7 +624,10 @@ public function startMigration(
614
624
}
615
625
616
626
// Processing "update file" changes.
617
- if (isset ($ versionInfo ['update_files ' ]) && !empty ($ versionInfo ['update_files ' ]) && $ onlyUpdateDatabase == false ) {
627
+ if (isset ($ versionInfo ['update_files ' ]) &&
628
+ !empty ($ versionInfo ['update_files ' ]) &&
629
+ $ onlyUpdateDatabase == false
630
+ ) {
618
631
$ sqlToInstall = $ installPath .$ versionInfo ['update_files ' ];
619
632
if (is_file ($ sqlToInstall ) && file_exists ($ sqlToInstall )) {
620
633
if ($ dryRun ) {
@@ -650,27 +663,52 @@ public function startMigration(
650
663
$ this ->getRootSys ().'/main/inc/lib/custom_pages.class.php ' ,
651
664
$ this ->getRootSys ().'/main/install/install.lib.php ' ,
652
665
$ this ->getRootSys ().'/main/inc/lib/display.lib.php ' ,
653
- $ this ->getRootSys ().'/main/inc/lib/group_portal_manager.lib.php ' ,
666
+ // $this->getRootSys().'/main/inc/lib/group_portal_manager.lib.php',
654
667
$ this ->getRootSys ().'/main/inc/lib/model.lib.php ' ,
655
668
$ this ->getRootSys ().'/main/inc/lib/events.lib.php ' ,
656
669
$ this ->getRootSys ().'/main/inc/lib/extra_field.lib.php ' ,
657
670
$ this ->getRootSys ().'/main/inc/lib/extra_field_value.lib.php ' ,
658
671
$ this ->getRootSys ().'/main/inc/lib/urlmanager.lib.php ' ,
659
672
$ this ->getRootSys ().'/main/inc/lib/usermanager.lib.php ' ,
673
+
674
+ $ this ->getRootSys ().'/vendor/sylius/translation/Model/TranslatableInterface.php ' ,
675
+ $ this ->getRootSys ().'/vendor/sylius/attribute/Model/AttributeTranslationInterface.php ' ,
676
+ $ this ->getRootSys ().'/vendor/sylius/resource/Model/TimestampableInterface.php ' ,
677
+ $ this ->getRootSys ().'/vendor/sylius/translation/Model/AbstractTranslatable.php ' ,
678
+ $ this ->getRootSys ().'/vendor/sylius/attribute/Model/AttributeInterface.php ' ,
679
+ $ this ->getRootSys ().'/vendor/sylius/attribute/Model/Attribute.php ' ,
660
680
$ this ->getRootSys ().'/src/Chamilo/CoreBundle/Entity/ExtraField.php ' ,
661
- $ this ->getRootSys ().'/src/Chamilo/CoreBundle/Entity/ExtraFieldOptions.php '
681
+ $ this ->getRootSys ().'/src/Chamilo/CoreBundle/Entity/ExtraFieldOptions.php ' ,
662
682
];
663
683
664
684
if ($ runFixIds ) {
665
685
foreach ($ filesToLoad as $ file ) {
666
- require_once $ file ;
686
+ if (file_exists ($ file )) {
687
+ require_once $ file ;
688
+ }
667
689
}
668
690
669
691
$ output ->writeln ("<comment>Run fixIds function </info> " );
670
692
fixIds ($ em );
693
+ } else {
694
+ $ output ->writeln ("<comment>fixIds NOT run</info> " );
695
+ }
696
+
697
+ if ($ runLpFix ) {
698
+ foreach ($ filesToLoad as $ file ) {
699
+ if (file_exists ($ file )) {
700
+ require_once $ file ;
701
+ }
702
+
703
+ }
704
+
705
+ $ output ->writeln ("<comment>Run fixLpId function </info> " );
706
+ fixLpId ($ conn , true );
707
+ } else {
708
+ $ output ->writeln ("<comment>fixLpId NOT run</info> " );
671
709
}
672
710
673
- if (method_exists ('fixPostGroupIds ' ) &&
711
+ if (function_exists ('fixPostGroupIds ' ) &&
674
712
$ versionInfo ['migrations_yml ' ] == 'V111.yml '
675
713
) {
676
714
foreach ($ filesToLoad as $ file ) {
@@ -681,14 +719,12 @@ public function startMigration(
681
719
} else {
682
720
$ output ->writeln ("<comment>Not found function: fixPostGroupIds</info> " );
683
721
}
684
-
685
722
} catch (\Exception $ e ) {
686
723
$ output ->write (sprintf ('<error>Migration failed. Error %s</error> ' , $ e ->getMessage ()));
687
724
688
725
throw $ e ;
689
726
}
690
727
691
-
692
728
return false ;
693
729
}
694
730
0 commit comments