From 50c0668849938f977362821026614e6149fa4dfd Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 29 Feb 2024 09:07:40 +0200 Subject: [PATCH] UHF-9566: Fix deprecated call abs(): Passing null to parameter #1 `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. --- hdbt.theme | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hdbt.theme b/hdbt.theme index 6e1e00823..50a183bab 100644 --- a/hdbt.theme +++ b/hdbt.theme @@ -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(); }