From 014d624e17bdf06fa1711db3238819fe095a77f8 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Sat, 28 Oct 2023 21:18:57 +0200
Subject: [PATCH] fix: correct bugs due to updated dependencies

---
 Dockerfile                                 | 12 +++++++-----
 database/Config.php                        |  2 +-
 database/backends/PostgresSmartBackend.php | 19 +++++++++++++------
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 444ed1b..7a5b6be 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,12 @@
-FROM k8r.eu/justjanne/php:latest
+FROM trafex/php-nginx:latest
+
+USER root
 
 RUN apk add --no-cache --update \
-    php-json \
-    php-pdo_sqlite \
-    php-pdo_pgsql
+    php82-json \
+    php82-pdo_sqlite \
+    php82-pdo_pgsql
 
 USER nobody
 
-ADD . /var/www/html/
\ No newline at end of file
+ADD . /var/www/html/
diff --git a/database/Config.php b/database/Config.php
index 7df6c1e..6d5070f 100644
--- a/database/Config.php
+++ b/database/Config.php
@@ -20,7 +20,7 @@ class Config
         $this->database_connector = $database_connector;
         $this->username = $username;
         $this->password = $password;
-        $this->path_prefix = $path_prefix;
+        $this->path_prefix = rtrim($path_prefix, "/");
         $this->backend = $backend;
         $this->database_options = $options;
         $this->enable_ranking = $enable_ranking;
diff --git a/database/backends/PostgresSmartBackend.php b/database/backends/PostgresSmartBackend.php
index 89b2c03..def8963 100644
--- a/database/backends/PostgresSmartBackend.php
+++ b/database/backends/PostgresSmartBackend.php
@@ -35,12 +35,19 @@ class PostgresSmartBackend implements Backend
 
     function rankingParameters(): array
     {
-        return [
-            ":config_normalization",
-            ":weight_content",
-            ":weight_type",
-            ":weight_time"
-        ];
+        if ($this->enable_ranking) {
+            return [
+                ":config_normalization",
+                ":weight_content",
+                ":weight_type",
+                ":weight_time"
+            ];
+        } else {
+            return [
+                ":weight_type",
+                ":weight_time"
+            ];
+        }
     }
 
     private function rankingFunction(): string
-- 
GitLab