Index: enrol/flatfile/lib.php
===================================================================
--- enrol/flatfile/lib.php	(revision 47)
+++ enrol/flatfile/lib.php	(working copy)
@@ -131,6 +131,12 @@
                         continue;
                     }
 
+                    // can't enrol directly on a meta course
+                    if ($meta = $DB->get_record('enrol', array('courseid' => $fields[3], 'enrol' => 'meta'))) {
+                        $this->log .= "Invalid meta course specified in field 4 - ignoring line\n";
+                        continue;
+                    }
+
                     // Either field[1] is a name that appears in the mapping,
                     // or it's an actual short name. It has to be one or the
                     // other, or we don't get to this point.
Index: search/lib.php
===================================================================
--- search/lib.php	(revision 47)
+++ search/lib.php	(working copy)
@@ -36,7 +36,7 @@
     global $CFG, $DB;
     
     $searchables = array();
-    $searchables_names = array();
+    $searchables_names = array(); 
     
 /// get all installed modules
     if ($mods = $DB->get_records('modules', null, 'name', 'id,name')){
Index: lang/en/error.php
===================================================================
--- lang/en/error.php	(revision 47)
+++ lang/en/error.php	(working copy)
@@ -155,6 +155,7 @@
 $string['cannotusepage'] = 'Only teachers and administrators can use this page';
 $string['cannotusepage2'] = 'Sorry, you may not use this page';
 $string['cannotviewprofile'] = 'You cannot view the profile of this user';
+$string['cantenrolonmetacourse'] = 'Cannot enrol directly on meta course {$a}';
 $string['cannotviewreport'] = 'You cannot view this report';
 $string['cannotwritefile'] = 'Cannot write to file ({$a})';
 $string['commentmisconf'] = 'Comment ID is misconfigured';
Index: admin/uploaduser.php
===================================================================
--- admin/uploaduser.php	(revision 47)
+++ admin/uploaduser.php	(working copy)
@@ -722,6 +722,14 @@
             }
             $courseid      = $ccache[$shortname]->id;
             $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+
+            // We should not be able to enrol users directly on metacourses. They should
+            // be enrolled on one of the component courses instead.
+            if ($meta = $DB->get_record('enrol', array('courseid' => $courseid, 'enrol' => 'meta'))) {
+            	$upt->track('enrolments', get_string('cantenrolonmetacourse', 'error', s($shortname)), 'error');
+            	continue;
+            }
+
             if (!isset($manualcache[$courseid])) {
                 $manualcache[$courseid] = false;
                 if ($manual) {
