Warnings for empty table - header/empty rows

Created on 20 January 2023, over 1 year ago
Updated 31 January 2024, 8 months ago

Problem/Motivation

Empty tables cause a ton of the following warnings - because of the foreach on each field, $last_render doesn't work on empty

Notice: Undefined property: views_handler_field_date::$last_render in template_preprocess_datatables_view() (line 290 of /srv/www/en-besqueda.tma.deen-gc.ca/tma/sites/all/modules/datatables/datatables.module).

Notice: Undefined property: views_handler_field_node::$last_render in template_preprocess_datatables_view() (line 293 of /srv/www/en-besqueda.tma.deen-gc.ca/tma/sites/all/modules/datatables/datatables.module).

And this one, the current validation to check if there are rows is not considering that the array is multiarray, so it is passing an empty array to the template causing the warning.
Notice: Undefined offset: 0 in include() (line 33 of /srv/www/en-besqueda.tma.deen-gc.ca/tma/sites/all/modules/datatables/views/datatables-view.tpl.php).

Steps to reproduce

Create a view,
set the view as DataTable,
add filter to the view that will cause not results,
check the database logs

Proposed resolution

Fix the validation:
!$vars['rows']
to consider empty arrays like this
Array ( [0] => Array ( [0] => ) )

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇨🇦Canada blanca.esqueda

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024