Bug when empty results

Created on 11 January 2018, over 6 years ago
Updated 25 October 2023, 8 months ago

Hi,
I have a view with relationships and contextual filters.
When the view has no results, the view crashes due to Views Tree.
Doing some debugging I was able to pinpoint to this part of the code:

$items[] = $rows[$i] . call_user_func(__FUNCTION__, $variables); 

(views_tree.module line 132)

After a bit of investigation it seems this is due to the assignment above $variables['parent'] = $record->views_tree_main; assuming views_tree_main is filled in, when it is in fact 0.

By adding a check to that variable it's fixed.

So changing

  foreach ($result as $i => $record) {
    if ($record->views_tree_parent == $parent) {
      $variables['parent'] = $record->views_tree_main;
      $items[] = $rows[$i] . call_user_func(__FUNCTION__, $variables);
    }
  }

to

  foreach ($result as $i => $record) {
    if (!empty($record->views_tree_main) && $record->views_tree_parent == $parent) {
      $variables['parent'] = $record->views_tree_main;
      $items[] = $rows[$i] . call_user_func(__FUNCTION__, $variables);
    }
  }
πŸ› Bug report
Status

Needs work

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia kyuubi

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

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.69.0 2024