Skip to content

Commit d36aff9

Browse files
committed
Internal: Migration: #fix issue with c_tool parent not set - refs BT#23211
1 parent 0c5c2c9 commit d36aff9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/CoreBundle/Migrations/Schema/V200/Version20251229113500.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function up(Schema $schema): void
7676
$this->write(\sprintf('Updated resource_link rows: %d', $affected));
7777

7878
// Create missing links (rare, but safe)
79+
// Could be optimized by grouping by course
7980
$sqlMissing = \sprintf(
8081
'SELECT ct.iid, ct.c_id, ct.session_id, ct.%s AS node_id, ct.visibility
8182
FROM c_tool ct
@@ -114,7 +115,8 @@ public function up(Schema $schema): void
114115
continue;
115116
}
116117

117-
$courseRef = $this->entityManager->getReference(Course::class, $courseId);
118+
// Could be optimized by fetching only the resource_node_id of the course
119+
$courseRef = $this->entityManager->find(Course::class, $courseId);
118120
$sessionRef = $sessionId > 0
119121
? $this->entityManager->getReference(Session::class, $sessionId)
120122
: null;
@@ -124,6 +126,7 @@ public function up(Schema $schema): void
124126
: ResourceLink::VISIBILITY_DRAFT;
125127

126128
// Create link for the exact same context (course + session, group/user null)
129+
$ctool->setParent($courseRef);
127130
$ctool->addCourseLink($courseRef, $sessionRef, null, $linkVisibility);
128131

129132
$this->entityManager->persist($ctool);

0 commit comments

Comments
 (0)