? drupal-755586-20.patch
? drupal-755586-27.patch
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1259
diff -u -p -r1.1259 common.inc
--- includes/common.inc	20 Nov 2010 08:27:52 -0000	1.1259
+++ includes/common.inc	20 Nov 2010 10:18:07 -0000
@@ -3060,7 +3060,12 @@ function drupal_aggregate_css(&$css_grou
       // the group's data property to the file path of the aggregate file.
       case 'file':
         if ($group['preprocess'] && $preprocess_css) {
-          $css_groups[$key]['data'] = drupal_build_css_cache($group['items']);
+          $uri = drupal_build_css_cache($group['items']);
+          // Only include the file if was written successfully. Errors are
+          // logged using watchdog.
+          if ($uri) {
+            $css_groups[$key]['data'] = $uri;
+          }
         }
         break;
       // Aggregate all inline CSS content into the group's data property.
@@ -4064,6 +4069,8 @@ function drupal_get_js($scope = 'header'
     $items['settings']['data'][] = $setting;
   }
 
+
+  $preprocessed_indexes = array();
   // Loop through the JavaScript to construct the rendered output.
   $element = array(
     '#tag' => 'script',
@@ -4096,16 +4103,15 @@ function drupal_get_js($scope = 'header'
         break;
 
       case 'file':
+        $index++;
         $js_element = $element;
-        if (!$item['preprocess'] || !$preprocess_js) {
-          if ($item['defer']) {
-            $js_element['#attributes']['defer'] = 'defer';
-          }
-          $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
-          $js_element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
-          $processed[$index++] = theme('html_tag', array('element' => $js_element));
+        if ($item['defer']) {
+          $js_element['#attributes']['defer'] = 'defer';
         }
-        else {
+        $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
+        $js_element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
+        $processed[$index] = theme('html_tag', array('element' => $js_element));
+        if ($item['preprocess'] && $preprocess_js) {
           // By increasing the index for each aggregated file, we maintain
           // the relative ordering of JS by weight. We also set the key such
           // that groups are split by items sharing the same 'group' value and
@@ -4116,6 +4122,7 @@ function drupal_get_js($scope = 'header'
           $key = 'aggregate_' . $item['group'] . '_' . $item['every_page'] . '_' . $index;
           $processed[$key] = '';
           $files[$key][$item['data']] = $item;
+          $preprocessed_indexes[$key] = $index;
         }
         break;
 
@@ -4142,6 +4149,9 @@ function drupal_get_js($scope = 'header'
         $js_element = $element;
         $js_element['#attributes']['src'] = $preprocess_file;
         $processed[$key] = theme('html_tag', array('element' => $js_element));
+
+        // Remove individual files from the processed list, these have been written to the aggregated file
+        unset($processed[$preprocessed_indexes[$key]]);
       }
     }
   }
