[Drupal] [Solved] Recoverable fatal error: Argument 1 passed to drupal_attributes()

| | 1 min read

We were working on creating a custom Drupal 7 module for making the comment management better. At some point, we started getting an error. Since the error came during the development, we were almost sure that it was from the custom module only.

Taking a close look at the error details can actually help debugging. Here is the error:

Recoverable fatal error: Argument 1 passed to drupal_attributes() must be of the type array, null given, called in /home/user/public_html/drupal-7/includes/theme.inc on line 1984 and defined in drupal_attributes() (line 2403 of /home/user/public_html/drupal-7/includes/common.inc).

Finally, we found the issue. The call to the theme function should pass an associative array for Drupal 7. We have done the following:

Change

$output = theme_table(array('header' => $header, 'rows' => $rows));

to

$output = theme('table', array('header' => $header, 'rows' => $rows));

We can help you further with other aspects as well. Just get in touch with us.