From 3105ea4b8cc57c73f6c4507a86a07dd3e9a17352 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 2 Oct 2023 09:19:55 +0000
Subject: [PATCH] fixes #3029

Closes #3029

Merge request studip/studip!2036
---
 lib/classes/StudipCache.class.php       | 32 ++++++++++++++++
 lib/classes/StudipCacheProxy.php        | 15 ++++++++
 lib/classes/StudipDbCache.class.php     |  2 +-
 lib/classes/StudipFileCache.class.php   |  6 +--
 lib/classes/StudipMemcachedCache.php    |  2 +-
 lib/classes/StudipMemoryCache.class.php | 15 ++++++++
 lib/classes/StudipRedisCache.class.php  |  2 +-
 lib/classes/StudipSystemCache.class.php | 49 -------------------------
 8 files changed, 66 insertions(+), 57 deletions(-)
 delete mode 100644 lib/classes/StudipSystemCache.class.php

diff --git a/lib/classes/StudipCache.class.php b/lib/classes/StudipCache.class.php
index 79e80e36f5f..ba929f9bcff 100644
--- a/lib/classes/StudipCache.class.php
+++ b/lib/classes/StudipCache.class.php
@@ -59,4 +59,36 @@ interface StudipCache
      * @return bool     returns TRUE on success or FALSE on failure.
      */
     public function write($name, $content, $expires = self::DEFAULT_EXPIRATION);
+
+    /**
+     * @return string A translateable display name for this cache class.
+     */
+    public static function getDisplayName(): string;
+
+    /**
+     * Get some statistics from cache, like number of entries, hit rate or
+     * whatever the underlying cache provides.
+     * Results are returned in form of an array like
+     *      "[
+     *          [
+     *              'name' => <displayable name>
+     *              'value' => <value of the current stat>
+     *          ]
+     *      ]"
+     *
+     * @return array
+     */
+    public function getStats(): array;
+
+    /**
+     * Return the Vue component name and props that handle configuration.
+     * The associative array is of the form
+     *  [
+     *      'component' => <Vue component name>,
+     *      'props' => <Properties for component>
+     *  ]
+     *
+     * @return array
+     */
+    public static function getConfig(): array;
 }
diff --git a/lib/classes/StudipCacheProxy.php b/lib/classes/StudipCacheProxy.php
index 74df560789a..686f8129d68 100644
--- a/lib/classes/StudipCacheProxy.php
+++ b/lib/classes/StudipCacheProxy.php
@@ -99,4 +99,19 @@ class StudipCacheProxy implements StudipCache
 
         return $this->actual_cache->write($key, $content, $expires);
     }
+
+    public static function getDisplayName(): string
+    {
+        return static::class;
+    }
+
+    public function getStats(): array
+    {
+        return $this->actual_cache->getStats();
+    }
+
+    public static function getConfig(): array
+    {
+        return [];
+    }
 }
diff --git a/lib/classes/StudipDbCache.class.php b/lib/classes/StudipDbCache.class.php
index 38fdee840fb..865825e2588 100644
--- a/lib/classes/StudipDbCache.class.php
+++ b/lib/classes/StudipDbCache.class.php
@@ -7,7 +7,7 @@
  *
  * @author    Elmar Ludwig <elmar.ludwig@uos.de>
  */
-class StudipDbCache implements StudipSystemCache
+class StudipDbCache implements StudipCache
 {
 
     /**
diff --git a/lib/classes/StudipFileCache.class.php b/lib/classes/StudipFileCache.class.php
index 8e46d253379..9eae66c1fba 100644
--- a/lib/classes/StudipFileCache.class.php
+++ b/lib/classes/StudipFileCache.class.php
@@ -31,7 +31,7 @@
  * @author    André Noack <noack@data-quest.de>
  * @version   2
  */
-class StudipFileCache implements StudipSystemCache
+class StudipFileCache implements StudipCache
 {
     use StudipCacheKeyTrait;
 
@@ -236,8 +236,6 @@ class StudipFileCache implements StudipSystemCache
     /**
      * Return statistics.
      *
-     * @StudipSystemCache::getStats()
-     *
      * @return array|array[]
      */
     public function getStats(): array
@@ -253,8 +251,6 @@ class StudipFileCache implements StudipSystemCache
     /**
      * Return the Vue component name and props that handle configuration.
      *
-     * @see StudipSystemCache::getConfig()
-     *
      * @return array
      */
     public static function getConfig(): array
diff --git a/lib/classes/StudipMemcachedCache.php b/lib/classes/StudipMemcachedCache.php
index 619a61ed91c..0e44dd57e1c 100644
--- a/lib/classes/StudipMemcachedCache.php
+++ b/lib/classes/StudipMemcachedCache.php
@@ -21,7 +21,7 @@
  * @since   5.0
  */
 
-class StudipMemcachedCache implements StudipSystemCache
+class StudipMemcachedCache implements StudipCache
 {
     use StudipCacheKeyTrait;
 
diff --git a/lib/classes/StudipMemoryCache.class.php b/lib/classes/StudipMemoryCache.class.php
index 57b35f9a4df..d38385a8ec4 100644
--- a/lib/classes/StudipMemoryCache.class.php
+++ b/lib/classes/StudipMemoryCache.class.php
@@ -66,4 +66,19 @@ class StudipMemoryCache implements StudipCache
 
         return true;
     }
+
+    public static function getDisplayName(): string
+    {
+        return 'Memory cache';
+    }
+
+    public function getStats(): array
+    {
+        return [];
+    }
+
+    public static function getConfig(): array
+    {
+        return [];
+    }
 }
diff --git a/lib/classes/StudipRedisCache.class.php b/lib/classes/StudipRedisCache.class.php
index 43a585f7ba1..c485b787b52 100644
--- a/lib/classes/StudipRedisCache.class.php
+++ b/lib/classes/StudipRedisCache.class.php
@@ -8,7 +8,7 @@
  * @subpackage  cache
  * @since       Stud.IP 5.0
  */
-class StudipRedisCache implements StudipSystemCache
+class StudipRedisCache implements StudipCache
 {
     use StudipCacheKeyTrait;
 
diff --git a/lib/classes/StudipSystemCache.class.php b/lib/classes/StudipSystemCache.class.php
deleted file mode 100644
index 895d1216653..00000000000
--- a/lib/classes/StudipSystemCache.class.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * An interface which has to be implemented by caches available for administration
- * via Stud.IP GUI
- *
- * @package    studip
- * @subpackage lib
- *
- * @author     Thomas Hackl <studip@thomas-hackl.name>
- * @copyright  2021 Stud.IP Core-Group
- * @since      Stud.IP 5.0
- * @license    GPL2 or any later version
- */
-
-interface StudipSystemCache extends StudipCache
-{
-
-    /**
-     * @return string A translateable display name for this cache class.
-     */
-    public static function getDisplayName(): string;
-
-    /**
-     * Get some statistics from cache, like number of entries, hit rate or
-     * whatever the underlying cache provides.
-     * Results are returned in form of an array like
-     *      "[
-     *          [
-     *              'name' => <displayable name>
-     *              'value' => <value of the current stat>
-     *          ]
-     *      ]"
-     *
-     * @return array
-     */
-    public function getStats(): array;
-
-    /**
-     * Return the Vue component name and props that handle configuration.
-     * The associative array is of the form
-     *  [
-     *      'component' => <Vue component name>,
-     *      'props' => <Properties for component>
-     *  ]
-     *
-     * @return array
-     */
-    public static function getConfig(): array;
-}
-- 
GitLab