Browse Source

Validate error when copying a course BT#15412

Julio Montoya 6 years ago
parent
commit
c5b29251c7
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

+ 9 - 7
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@@ -2591,13 +2591,15 @@ class CourseRestorer
             foreach ($resources[RESOURCE_LEARNPATH_CATEGORY] as $id => $item) {
                 /** @var CLpCategory $lpCategory */
                 $lpCategory = $item->object;
-                $values = [
-                    'c_id' => $this->destination_course_id,
-                    'name' => $lpCategory->getName(),
-                ];
-                $categoryId = \learnpath::createCategory($values);
-                if ($categoryId) {
-                    $this->course->resources[RESOURCE_LEARNPATH_CATEGORY][$id]->destination_id = $categoryId;
+                if ($lpCategory) {
+                    $values = [
+                        'c_id' => $this->destination_course_id,
+                        'name' => $lpCategory->getName(),
+                    ];
+                    $categoryId = \learnpath::createCategory($values);
+                    if ($categoryId) {
+                        $this->course->resources[RESOURCE_LEARNPATH_CATEGORY][$id]->destination_id = $categoryId;
+                    }
                 }
             }
         }