@@ -381,12 +381,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
381381
382382 $ lastItem = count ($ versionsToRun );
383383 $ counter = 0 ;
384- $ runFixIds = false ;
384+
385385 foreach ($ versionsToRun as $ versionItem => $ versionInfo ) {
386- if ($ lastItem == $ counter ) {
386+ $ runFixIds = false ;
387+ $ runLpFix = false ;
388+ if ($ versionItem === '1.10.0 ' ) {
387389 $ runFixIds = true ;
388390 }
389391
392+ if ($ versionItem === '1.11.0 ' ) {
393+ $ runLpFix = true ;
394+ }
395+
390396 if (isset ($ versionInfo ['require_update ' ]) &&
391397 $ versionInfo ['require_update ' ] == true
392398 ) {
@@ -404,12 +410,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
404410 $ removeUnusedTables ,
405411 $ input ,
406412 $ runFixIds ,
407- $ onlyUpdateDatabase
413+ $ onlyUpdateDatabase ,
414+ $ runLpFix
408415 );
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 ("---------------------------------------------------------------- " );
412419 $ output ->writeln ("---------------------------------------------------------------- " );
420+ $ currentVersion = $ versionItem ;
413421 } else {
414422 $ currentVersion = $ versionItem ;
415423 $ 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)
486494 /**
487495 * Starts a migration
488496 *
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
493501 * @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
498507 *
499508 * @return bool
500509 * @throws \Exception
@@ -508,7 +517,8 @@ public function startMigration(
508517 $ removeUnusedTables = false ,
509518 InputInterface $ mainInput ,
510519 $ runFixIds = true ,
511- $ onlyUpdateDatabase = false
520+ $ onlyUpdateDatabase = false ,
521+ $ runLpFix = false
512522 ) {
513523 // Cleaning query list.
514524 $ this ->queryList = array ();
@@ -614,7 +624,10 @@ public function startMigration(
614624 }
615625
616626 // 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+ ) {
618631 $ sqlToInstall = $ installPath .$ versionInfo ['update_files ' ];
619632 if (is_file ($ sqlToInstall ) && file_exists ($ sqlToInstall )) {
620633 if ($ dryRun ) {
@@ -650,27 +663,52 @@ public function startMigration(
650663 $ this ->getRootSys ().'/main/inc/lib/custom_pages.class.php ' ,
651664 $ this ->getRootSys ().'/main/install/install.lib.php ' ,
652665 $ 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',
654667 $ this ->getRootSys ().'/main/inc/lib/model.lib.php ' ,
655668 $ this ->getRootSys ().'/main/inc/lib/events.lib.php ' ,
656669 $ this ->getRootSys ().'/main/inc/lib/extra_field.lib.php ' ,
657670 $ this ->getRootSys ().'/main/inc/lib/extra_field_value.lib.php ' ,
658671 $ this ->getRootSys ().'/main/inc/lib/urlmanager.lib.php ' ,
659672 $ 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 ' ,
660680 $ 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 ' ,
662682 ];
663683
664684 if ($ runFixIds ) {
665685 foreach ($ filesToLoad as $ file ) {
666- require_once $ file ;
686+ if (file_exists ($ file )) {
687+ require_once $ file ;
688+ }
667689 }
668690
669691 $ output ->writeln ("<comment>Run fixIds function </info> " );
670692 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> " );
671709 }
672710
673- if (method_exists ('fixPostGroupIds ' ) &&
711+ if (function_exists ('fixPostGroupIds ' ) &&
674712 $ versionInfo ['migrations_yml ' ] == 'V111.yml '
675713 ) {
676714 foreach ($ filesToLoad as $ file ) {
@@ -681,14 +719,12 @@ public function startMigration(
681719 } else {
682720 $ output ->writeln ("<comment>Not found function: fixPostGroupIds</info> " );
683721 }
684-
685722 } catch (\Exception $ e ) {
686723 $ output ->write (sprintf ('<error>Migration failed. Error %s</error> ' , $ e ->getMessage ()));
687724
688725 throw $ e ;
689726 }
690727
691-
692728 return false ;
693729 }
694730
0 commit comments