theme_datatable() assumes that all the items in the $header array have datatable options:

    // or in each header definition.
    if (!isset($datatable_options['aoColumns'])) {
      foreach ($header as $key => $cell) {
        $datatable_options['aoColumns'][] = $cell['datatable_options'];
        unset($header[$key]['datatable_options']);
      }
    }

This causes a fatal if they are not:

( ! ) Fatal error: Cannot unset string offsets in sites/all/modules/contrib/datatables/datatables.module on line 166

Note that the docs say that this should work fine:

* @param $header
* An array containing the table headers. Each element of the array can be
* either a localized string or an associative array with the following keys:
* - "data": The localized title of the table column.
* - Any HTML attributes, such as "colspan", to apply to the column header
* cell.
* - "datatable_options": An associative array containing DataTable column
* specific features/options.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duellj’s picture

Status: Active » Fixed

Thanks @joachim, fixed in dev branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Dave Reid’s picture

Status: Closed (fixed) » Active

Very sorry to re-open this, but I still believe this is not correct, because the errors are caused by the unset() call itself because $headers[$key] is a string, and not an array.

Dave Reid’s picture

Status: Active » Needs review
FileSize
549 bytes

Here is the real fix.

duellj’s picture

Status: Needs review » Fixed

Thanks Dave. Commmitted to 7.x-1.x-dev branch

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • duellj committed 79abf3b on 7.x-1.x, 7.x-2.x
    Issue #1904140 - Fixes fatal error when headers are strings
    
  • duellj committed b84ef1e on 7.x-1.x, 7.x-2.x
    Issue #1904140 by Dave Reid | joachim: Fixed Fatal error: Cannot unset...