Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.101
diff -u -r1.101 common.test
--- modules/simpletest/tests/common.test	9 Jan 2010 23:36:55 -0000	1.101
+++ modules/simpletest/tests/common.test	15 Jan 2010 22:15:13 -0000
@@ -781,6 +781,19 @@
       $this->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
     }
   }
+
+  /**
+   * Test that during aggregation @import commands are restored when loading of
+   * the stylesheet fails.
+   */
+  function testRestoreAtImportOnFailure() {
+    $input_css = <<<EOS
+@import url(non-existing-file.css);
+EOS;
+    $output_css = drupal_load_stylesheet_content($input_css, FALSE);
+
+    $this->assertEqual($input_css, $output_css, t('@import command is restored succesfully when stylesheet could not be loaded.'));
+  }
 }
 
 /**
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1090
diff -u -r1.1090 common.inc
--- includes/common.inc	14 Jan 2010 18:45:17 -0000	1.1090
+++ includes/common.inc	15 Jan 2010 22:15:12 -0000
@@ -3437,7 +3437,8 @@
  * @param $optimize
  *   Defines if CSS contents should be compressed or not.
  * @return
- *   Contents of the stylesheet, including any resolved @import commands.
+ *   Contents of the stylesheet, including any resolved @import commands, or
+ *   FALSE when the stylesheet could not be loaded.
  */
 function drupal_load_stylesheet($file, $optimize = NULL) {
   // $_optimize does not use drupal_static as it is set by $optimize.
@@ -3462,6 +3463,9 @@
     // Change back directory.
     chdir($cwd);
   }
+  else {
+    return FALSE;
+  }
 
   return $contents;
 }
@@ -3509,6 +3513,10 @@
   $filename = $matches[1];
   // Load the imported stylesheet and replace @import commands in there as well.
   $file = drupal_load_stylesheet($filename);
+  // Restore @import command when stylesheet could not be loaded.
+  if ($file === FALSE) {
+    return '@import url(' . $filename . ');';
+  }
 
   // Determine the file's directory.
   $directory = dirname($filename);
