From c03ad2f40dd18c6f9800787afe5444b2f33f2c55 Mon Sep 17 00:00:00 2001 From: Muhammad Arnaldo Date: Wed, 24 Dec 2025 15:47:54 +0700 Subject: [PATCH] MDL-87433 course: Add sorting to get_nearest_editable_subcategory Add ORDER BY to the query to ensure categories are returned in consistent order. This fixes random test failures, especially on PostgreSQL. --- course/classes/category.php | 1 + 1 file changed, 1 insertion(+) diff --git a/course/classes/category.php b/course/classes/category.php index 04f3abb0c58..d4ef42ae1a9 100644 --- a/course/classes/category.php +++ b/course/classes/category.php @@ -3274,6 +3274,7 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr ON uc.roleid = rc.roleid AND ( $eqpaths OR $likechild ) WHERE (ra.id IS NOT NULL OR uc.upath IS NOT NULL) + ORDER BY cc.sortorder, cc.id "; $params = [