Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.96
diff -u -p -r1.96 install.inc
--- includes/install.inc	15 Jul 2009 02:08:41 -0000	1.96
+++ includes/install.inc	17 Jul 2009 14:03:22 -0000
@@ -92,24 +92,29 @@ function drupal_load_updates() {
  *   Otherwise, FALSE.
  */
 function drupal_get_schema_versions($module) {
-  $updates = array();
-  $functions = get_defined_functions();
-  foreach ($functions['user'] as $function) {
-    if (strpos($function, $module . '_update_') === 0) {
-      $version = substr($function, strlen($module . '_update_'));
-      if (is_numeric($version)) {
-        $updates[] = $version;
+  $updates = &drupal_static(__FUNCTION__, array());
+  if (!$updates) {
+    $modules = module_list();
+    foreach ($modules as $module_name) {
+      $install_file = drupal_get_path('module', $module_name) . '/' . $module_name . '.install';
+      if (file_exists($install_file)) {
+        $contents = file_get_contents($install_file);
+        preg_match_all("/function (.*)/", $contents, $matches);
+        foreach ($matches[1] as $function) {
+          $version = substr(strtok($function, '('), strlen($module .'_update_'));
+          if (is_numeric($version)) {
+            $updates[$module_name][] = $version;
+            sort($updates[$module_name], SORT_NUMERIC);
+          }
+        }
       }
     }
   }
-  if (count($updates) == 0) {
+  if (empty($updates[$module])) {
     return FALSE;
   }
 
-  // Make sure updates are run in numeric order, not in definition order.
-  sort($updates, SORT_NUMERIC);
-
-  return $updates;
+  return $updates[$module];
 }
 
 /**
