Skip to content

Commit 7f10679

Browse files
committed
Fix issue when course is empty
1 parent da9e25c commit 7f10679

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

classes/output/featured_courses.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ class featured_courses implements renderable, templatable {
5656
*/
5757
public function __construct($coursesid) {
5858
global $DB;
59-
list($sql, $params) = $DB->get_in_or_equal($coursesid, SQL_PARAMS_NAMED);
59+
// First make sure that we have id in the table and not empty strings.
60+
$realcourseids = [];
61+
foreach($coursesid as $cid) {
62+
if ($cid && is_numeric($cid)) {
63+
$realcourseids[] = $cid;
64+
}
65+
}
66+
list($sql, $params) = $DB->get_in_or_equal($realcourseids, SQL_PARAMS_NAMED);
6067
$this->courses = $DB->get_records_select('course', 'id ' . $sql, $params);
6168
}
6269

0 commit comments

Comments
 (0)