Reproduce:

Create a table without a header with render array:
'limit' => array(
'#theme' => 'table',
'#rows' => $rows,
'#empty' => t('No credit purchases so far.'),
),
Where rows is an empty array.

This will throw error: Warning: Invalid argument supplied for foreach() in theme_table() (line 1676 of .../drupal/includes/theme.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aspilicious’s picture

Version: 7.1 » 8.x-dev
Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
1.07 KB

Totally untested but this could fix it.

aspilicious’s picture

Maybe isset needs to be replaced with "count".
Not sure.

blackra’s picture

Issue tags: -Needs backport to D7

#1: 1183554-header-warning-fix.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs backport to D7

The last submitted patch, 1183554-header-warning-fix.patch, failed testing.

jerdavis’s picture

Status: Needs work » Needs review
FileSize
927 bytes

Re-roll of patch from #1

BarisW’s picture

Status: Needs review » Reviewed & tested by the community

Works fine. Errors are gone and patch applies nicely.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Could we add a test for this?

droplet’s picture

BarisW’s picture

Patch looks good, thanks!

The last submitted patch, 8: 1183554-header-warning-fix-with-tests.patch, failed testing.

jhedstrom’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll
dimaro’s picture

Status: Needs work » Needs review
FileSize
912 bytes

Rerolled #8

Status: Needs review » Needs work

The last submitted patch, 13: header-warning-fix-with-test-1183554-13.patch, failed testing.

dimaro’s picture

Issue tags: -Needs reroll

Currently this issue doesn't need reroll

penyaskito’s picture

Issue tags: +SprintWeekend2015

Tagging per dimaro work.

mglaman’s picture

Version: 8.0.x-dev » 7.x-dev
FileSize
30.56 KB

This doesn't look to be an issue in D8 (see below). Also, the patch in #8 looks to be a patch against D7, changing the issue version because it may still exist there.

Header has an empty check

  $header_columns = 0;
  if (!empty($variables['header'])) {

As well as body and footer

  // Rows and footer have the same structure.
  $sections = array('rows' , 'footer');
  foreach ($sections as $section) {
    if (!empty($variables[$section])) {
      foreach ($variables[$section] as $row_key => $row) {
diddledani’s picture

Status: Needs work » Needs review
FileSize
907 bytes
  • recreated the patch with count($header) check instead of isset().
  • Setting issue to needs review for the testbot to pick up my version of the patch.
dcam’s picture

Status: Needs review » Needs work

There are tests in #8 that will need to be backported to D7 too.