Index: autoload.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autoload/autoload.module,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 autoload.module
--- autoload.module	27 Aug 2009 23:12:11 -0000	1.1.2.6
+++ autoload.module	1 Dec 2009 10:40:04 -0000
@@ -25,14 +25,33 @@ function autoload_class($class) {
     $lookup = autoload_get_lookup();
   }
 
-   if (!empty($lookup[$class])) {
-    // require() is safe because if the file were already included
-    // autoload wouldn't have been triggered.  The dirname() stuff
-    // is backported from Drupal 7 to get an absolute path, which
-    // includes faster on disk.
-    require dirname($_SERVER['SCRIPT_FILENAME']) .'/'. $lookup[$class];
+  if (!empty($lookup[$class])) {
+    //Work around for if being invoked from the command line (ie using drush)
+    if (autoload_is_cli()) {
+      // $_SERVER['SCRIPT_FILENAME'] is set to the path to drush, but drush sees to the finding of the path
+      require $lookup[$class];
+    }
+    else {
+       
+      // require() is safe because if the file were already included
+      // autoload wouldn't have been triggered.  The dirname() stuff
+      // is backported from Drupal 7 to get an absolute path, which
+      // includes faster on disk.
+      require dirname($_SERVER['SCRIPT_FILENAME']) .'/'. $lookup[$class];
+    }
   }
 }
+/**
+ * Check if PHP is being run as a CLI.
+ * This code is taken from Drush.
+ */
+function autoload_is_cli() {
+  if (php_sapi_name() == 'cgi') {
+    return (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0);
+  }
+
+  return (php_sapi_name() == 'cli');
+}
 
 /**
  * Build and return the lookup table for classes and interfaces.
