Skip to content

Commit 92d1f3f

Browse files
committed
Merge branch 'master' of github.com:chamilo/chamilo-lms
2 parents 8ce821d + c9d5605 commit 92d1f3f

File tree

2 files changed

+80
-77
lines changed

2 files changed

+80
-77
lines changed

.github/workflows/behat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
operating-system: [ubuntu-latest]
14-
php-versions: ['8.3', '8.4']
14+
php-versions: ['8.2', '8.3']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

src/CoreBundle/Controller/CourseMaintenanceController.php

Lines changed: 79 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,100 +1393,103 @@ private function filterLegacyCourseBySelection(object $course, array $selected):
13931393
};
13941394

13951395
// Forums flow
1396-
$selForums = array_fill_keys(array_map('strval', array_keys($selected['forum'] ?? [])), true);
1397-
if (!empty($selForums)) {
1398-
$forums = $getBucket($orig, 'forum');
1399-
$catsToKeep = [];
1396+
if (!empty($selected) && !empty($selected['forum'])) {
1397+
$selForums = array_fill_keys(array_map('strval', array_keys($selected['forum'])), true);
1398+
if (!empty($selForums)) {
1399+
$forums = $getBucket($orig, 'forum');
1400+
$catsToKeep = [];
1401+
1402+
foreach ($forums as $fid => $f) {
1403+
if (!isset($selForums[(string) $fid])) {
1404+
continue;
1405+
}
1406+
$e = (isset($f->obj) && \is_object($f->obj)) ? $f->obj : $f;
1407+
$cid = (int) ($e->forum_category ?? 0);
1408+
if ($cid > 0) {
1409+
$catsToKeep[$cid] = true;
1410+
}
1411+
}
14001412

1401-
foreach ($forums as $fid => $f) {
1402-
if (!isset($selForums[(string) $fid])) {
1403-
continue;
1413+
$threads = $getBucket($orig, 'thread');
1414+
$threadToKeep = [];
1415+
foreach ($threads as $tid => $t) {
1416+
$e = (isset($t->obj) && \is_object($t->obj)) ? $t->obj : $t;
1417+
if (isset($selForums[(string) ($e->forum_id ?? '')])) {
1418+
$threadToKeep[(int) $tid] = true;
1419+
}
14041420
}
1405-
$e = (isset($f->obj) && \is_object($f->obj)) ? $f->obj : $f;
1406-
$cid = (int) ($e->forum_category ?? 0);
1407-
if ($cid > 0) {
1408-
$catsToKeep[$cid] = true;
1421+
1422+
$posts = $getBucket($orig, 'post');
1423+
$postToKeep = [];
1424+
foreach ($posts as $pid => $p) {
1425+
$e = (isset($p->obj) && \is_object($p->obj)) ? $p->obj : $p;
1426+
if (isset($threadToKeep[(int) ($e->thread_id ?? 0)])) {
1427+
$postToKeep[(int) $pid] = true;
1428+
}
14091429
}
1410-
}
14111430

1412-
$threads = $getBucket($orig, 'thread');
1413-
$threadToKeep = [];
1414-
foreach ($threads as $tid => $t) {
1415-
$e = (isset($t->obj) && \is_object($t->obj)) ? $t->obj : $t;
1416-
if (isset($selForums[(string) ($e->forum_id ?? '')])) {
1417-
$threadToKeep[(int) $tid] = true;
1431+
$out = [];
1432+
foreach ($selected as $type => $ids) {
1433+
if (!\is_array($ids) || empty($ids)) {
1434+
continue;
1435+
}
1436+
$bucket = $getBucket($orig, (string) $type);
1437+
if (!empty($bucket)) {
1438+
$idsMap = array_fill_keys(array_map('strval', array_keys($ids)), true);
1439+
$out[$type] = array_intersect_key($bucket, $idsMap);
1440+
}
14181441
}
1419-
}
14201442

1421-
$posts = $getBucket($orig, 'post');
1422-
$postToKeep = [];
1423-
foreach ($posts as $pid => $p) {
1424-
$e = (isset($p->obj) && \is_object($p->obj)) ? $p->obj : $p;
1425-
if (isset($threadToKeep[(int) ($e->thread_id ?? 0)])) {
1426-
$postToKeep[(int) $pid] = true;
1443+
$forumCat = $getBucket($orig, 'Forum_Category');
1444+
if (!empty($forumCat)) {
1445+
$out['Forum_Category'] = array_intersect_key(
1446+
$forumCat,
1447+
array_fill_keys(array_map('strval', array_keys($catsToKeep)), true)
1448+
);
14271449
}
1428-
}
14291450

1430-
$out = [];
1431-
foreach ($selected as $type => $ids) {
1432-
if (!\is_array($ids) || empty($ids)) {
1433-
continue;
1451+
$forumBucket = $getBucket($orig, 'forum');
1452+
if (!empty($forumBucket)) {
1453+
$out['forum'] = array_intersect_key($forumBucket, $selForums);
14341454
}
1435-
$bucket = $getBucket($orig, (string) $type);
1436-
if (!empty($bucket)) {
1437-
$idsMap = array_fill_keys(array_map('strval', array_keys($ids)), true);
1438-
$out[$type] = array_intersect_key($bucket, $idsMap);
1455+
1456+
$threadBucket = $getBucket($orig, 'thread');
1457+
if (!empty($threadBucket)) {
1458+
$out['thread'] = array_intersect_key(
1459+
$threadBucket,
1460+
array_fill_keys(array_map('strval', array_keys($threadToKeep)), true)
1461+
);
14391462
}
1440-
}
14411463

1442-
$forumCat = $getBucket($orig, 'Forum_Category');
1443-
if (!empty($forumCat)) {
1444-
$out['Forum_Category'] = array_intersect_key(
1445-
$forumCat,
1446-
array_fill_keys(array_map('strval', array_keys($catsToKeep)), true)
1447-
);
1448-
}
1464+
$postBucket = $getBucket($orig, 'post');
1465+
if (!empty($postBucket)) {
1466+
$out['post'] = array_intersect_key(
1467+
$postBucket,
1468+
array_fill_keys(array_map('strval', array_keys($postToKeep)), true)
1469+
);
1470+
}
14491471

1450-
$forumBucket = $getBucket($orig, 'forum');
1451-
if (!empty($forumBucket)) {
1452-
$out['forum'] = array_intersect_key($forumBucket, $selForums);
1453-
}
1472+
if (!empty($out['forum']) && empty($out['Forum_Category']) && !empty($forumCat)) {
1473+
$out['Forum_Category'] = $forumCat;
1474+
}
14541475

1455-
$threadBucket = $getBucket($orig, 'thread');
1456-
if (!empty($threadBucket)) {
1457-
$out['thread'] = array_intersect_key(
1458-
$threadBucket,
1459-
array_fill_keys(array_map('strval', array_keys($threadToKeep)), true)
1460-
);
1461-
}
1476+
$course->resources = array_filter($out);
14621477

1463-
$postBucket = $getBucket($orig, 'post');
1464-
if (!empty($postBucket)) {
1465-
$out['post'] = array_intersect_key(
1466-
$postBucket,
1467-
array_fill_keys(array_map('strval', array_keys($postToKeep)), true)
1468-
);
1469-
}
1478+
$this->logDebug('[filterSelection] end', [
1479+
'kept_types' => array_keys($course->resources),
1480+
'forum_counts' => [
1481+
'Forum_Category' => \is_array($course->resources['Forum_Category'] ?? null) ? \count($course->resources['Forum_Category']) : 0,
1482+
'forum' => \is_array($course->resources['forum'] ?? null) ? \count($course->resources['forum']) : 0,
1483+
'thread' => \is_array($course->resources['thread'] ?? null) ? \count($course->resources['thread']) : 0,
1484+
'post' => \is_array($course->resources['post'] ?? null) ? \count($course->resources['post']) : 0,
1485+
],
1486+
]);
14701487

1471-
if (!empty($out['forum']) && empty($out['Forum_Category']) && !empty($forumCat)) {
1472-
$out['Forum_Category'] = $forumCat;
1488+
return $course;
14731489
}
1474-
1475-
$course->resources = array_filter($out);
1476-
1477-
$this->logDebug('[filterSelection] end', [
1478-
'kept_types' => array_keys($course->resources),
1479-
'forum_counts' => [
1480-
'Forum_Category' => \is_array($course->resources['Forum_Category'] ?? null) ? \count($course->resources['Forum_Category']) : 0,
1481-
'forum' => \is_array($course->resources['forum'] ?? null) ? \count($course->resources['forum']) : 0,
1482-
'thread' => \is_array($course->resources['thread'] ?? null) ? \count($course->resources['thread']) : 0,
1483-
'post' => \is_array($course->resources['post'] ?? null) ? \count($course->resources['post']) : 0,
1484-
],
1485-
]);
1486-
1487-
return $course;
14881490
}
14891491

1492+
14901493
// Generic + quiz/survey/gradebook flows
14911494
$alias = [
14921495
'tool_intro' => 'Tool introduction',

0 commit comments

Comments
 (0)