From f0861d1ffe4ab14ab02a7297854c5459298054f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de>
Date: Fri, 20 Apr 2018 11:22:07 +0200
Subject: [PATCH] refactor(search): clearer data flow

---
 inc/Ui/Search.php | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php
index 5601607f9..33506ad73 100644
--- a/inc/Ui/Search.php
+++ b/inc/Ui/Search.php
@@ -580,26 +580,20 @@ class Search extends Ui
                 $resultHeader[] = $restrictQueryToNSLink;
             }
 
-            $snippet = '';
-            $hits = '';
             $resultBody = [];
             $mtime = filemtime(wikiFN($id));
             $lastMod = '<span class="lastmod">' . $lang['lastmod'] . '</span> ';
             $lastMod .= '<time datetime="' . date_iso8601($mtime) . '" title="'.dformat($mtime).'">' . dformat($mtime, '%f') . '</time>';
+            $resultBody['meta'] = $lastMod;
             if ($cnt !== 0) {
                 $hits = '<span class="hits">' . $cnt . ' ' . $lang['hits'] . '</span>, ';
+                $resultBody['meta'] = $hits . $resultBody['meta'];
                 if ($num < FT_SNIPPET_NUMBER) { // create snippets for the first number of matches only
-                    $snippet = ft_snippet($id, $highlight);
+                    $resultBody['snippet'] = ft_snippet($id, $highlight);
                 }
                 $num++;
             }
 
-            $resultBody['meta'] = $hits . $lastMod;
-
-            if ($snippet) {
-                $resultBody['snippet'] = $snippet;
-            }
-
             $eventData = [
                 'resultHeader' => $resultHeader,
                 'resultBody' => $resultBody,
-- 
GitLab