From e3807c295f94f60764c215afe338cca62f5d61ee Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 15 Jan 2021 15:16:13 -0500
Subject: [PATCH] Less ambiguous weight check, for PHP 8 compatibility.

---
 .../src/VuFindSearch/Backend/Solr/SearchHandler.php       | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php
index 83559813047..d9ae9a91fff 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php
@@ -525,8 +525,8 @@ class SearchHandler
                     $this->munge($clausearray, $mungeValues, $internalJoin) .
                     ')';
                 // ...and add a weight if we have one
-                $weight = $sw[1];
-                if (null !== $weight && $weight && $weight > 0) {
+                $weight = intval($sw[1] ?? 0);
+                if ($weight > 0) {
                     $sstring .= '^' . $weight;
                 }
                 // push it onto the stack of clauses
@@ -539,8 +539,8 @@ class SearchHandler
                     $sstring = $field . ':(' . $mungeValues[$spec[0]] . ')';
                     // Add the weight if we have one. Yes, I know, it's redundant
                     // code.
-                    $weight = $spec[1];
-                    if (null !== $weight && $weight && $weight > 0) {
+                    $weight = intval($spec[1] ?? 0);
+                    if ($weight > 0) {
                         $sstring .= '^' . $weight;
                     }
                     // ..and push it on the stack of clauses
-- 
GitLab