Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1210
diff -u -p -r1.1210 common.inc
--- includes/common.inc	22 Aug 2010 12:46:21 -0000	1.1210
+++ includes/common.inc	27 Aug 2010 14:48:22 -0000
@@ -4819,7 +4819,20 @@ function drupal_system_listing($mask, $d
     require_once DRUPAL_ROOT . '/includes/file.inc';
   }
   foreach ($searchdir as $dir) {
-    $files = array_merge($files, file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth)));
+    $files_to_add = file_scan_directory($dir, $mask, array('key' => $key, 'min_depth' => $min_depth));
+
+    // Work out if there are anything in the $files array that will be
+    // overwritten on merging.
+    foreach (array_intersect_key($files_to_add, $files) as $file) {
+      // Get the .info file for this.
+      $info = drupal_parse_info_file(dirname($file->uri) . '/' . $file->name . '.info');
+
+      // If this is incompatible with Drupal core remove it from the array.
+      if ($info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+        unset($files_to_add[$file->name]);
+      }
+    }
+    $files = array_merge($files, $files_to_add);
   }
 
   return $files;
