-2
function drupal_build_css_cache($css) {
  $data = '';
  $uri = '';
  $map = variable_get('drupal_css_cache_files', array());
  // Create a new array so that only the file names are used to create the hash.
  // This prevents new aggregates from being created unnecessarily.
  $css_data = array();
  foreach ($css as $css_file) {
    $css_data[] = $css_file['data'];
  }

PHP Notice: Undefined index: data on line 3606. Line 3606 being: $css_data[] = $css_file['data'];

  • Notice: Undefined index can be ignored , and if you don't want to ignore split $css_file in foreach($css as $css_file_var => $css_file_value). – Nirpendra Patel Apr 13 '16 at 11:39
  • 4
    First, I would like to know what is problem and what do you expet? Second, please read this [Notice undefined index](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12770836#12770836) if you want to get rid of the error. –  Apr 13 '16 at 11:56
  • You might want to print_r $css_file to see the indexes that are available within the array – Markus Müller Apr 13 '16 at 12:42
  • @NirpendraPatel you should not just ignore notices. They may not crash your code directly, but most likely lead to some errors. In this case `$css_file['data']` seems to not exist, so you should check for the key and react to the result. – enricog Apr 13 '16 at 12:42
  • No, you must not ignore it. It's an indication that your input is not as expected, which means you may need additional validation of that input, or at least a check like `if (isset($css_file['data'])) $css_data[] = $css_file['data'];` – Michael Berkowski Apr 13 '16 at 12:42

4 Answers4

3

To avoid this error just test if the table fields was initialized with isset () .

// Before using $css_file['data'];
if (isset($css_file['data']))
{
    $css_data[] = $css_file['data'];   
}
DevLoots
  • 747
  • 1
  • 6
  • 21
1

It is just notice, that you have undefined index; you should first check if is it set:

if (isset($css_file['data'])) {
  $css_data[] = $css_file['data'];   
}

Otherwise you can turn off notice reporting (put this line at the beginning of your code):

error_reporting(E_ALL ^ E_NOTICE);
Legionar
  • 7,472
  • 2
  • 41
  • 70
0

PHP notice is telling you that $css_file has no key data. Check what you receive in $css variable.

Justinas
  • 41,402
  • 5
  • 66
  • 96
0

First, you should show what you've tried to fix the issue. As the error shows, it's caused because $css_file['data'] is undefined. You haven't shown us where $css_file is defined. $css_file['data'] is most likely not being defined.

Goose
  • 4,764
  • 5
  • 45
  • 84