MDL-27597 fix invalid results of get_categories when shallow is false
authorPetr Skoda <commits@skodak.org>
Fri, 5 Aug 2011 18:13:12 +0000 (20:13 +0200)
committerPetr Skoda <commits@skodak.org>
Fri, 5 Aug 2011 18:13:12 +0000 (20:13 +0200)
lib/datalib.php

index 8aa1f84..478156c 100644 (file)
@@ -847,7 +847,7 @@ function get_categories($parent='none', $sort=NULL, $shallow=true) {
                   FROM {course_categories} cc
                $ccjoin
                   JOIN {course_categories} ccp
                   FROM {course_categories} cc
                $ccjoin
                   JOIN {course_categories} ccp
-                       ON (cc.path LIKE ".$DB->sql_concat('ccp.path',"'%'").")
+                       ON ((cc.parent = ccp.id) OR (cc.path LIKE ".$DB->sql_concat('ccp.path',"'/%'")."))
                  WHERE ccp.id=?
                 $sort";
         $params = array($parent);
                  WHERE ccp.id=?
                 $sort";
         $params = array($parent);