Skip to content

Commit

Permalink
UHF-9566: Fix deprecated call abs(): Passing null to parameter #1
Browse files Browse the repository at this point in the history
`total_rows` was not defined if $variables['view']->total_rows is zero,
since `0 == NULL` evaluates to true. This patch ensures that total rows
is always defined so templates can use it without checking.
  • Loading branch information
hyrsky committed Feb 29, 2024
1 parent 13dbc7a commit 50c0668
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,8 @@ function hdbt_preprocess_views_view(&$variables): void {
$variables['pager_items_per_page'] = $variables['view']->pager->options['items_per_page'];
}
// Add total rows as a variable.
if ($variables['view']->total_rows != NULL) {
$variables['total_rows'] = $variables['view']->total_rows;
}
$variables['total_rows'] = $variables['view']->total_rows ?: 0;

if ($variables['view']->id() == 'service_list') {
$variables['is_ajax_request'] = \Drupal::request()->isXmlHttpRequest();
}
Expand Down

0 comments on commit 50c0668

Please sign in to comment.