[Scummvm-git-logs] scummvm-web master -> 85bbf617bbabf8be41d58a8032b6320c7fefd272

lephilousophe noreply at scummvm.org
Tue Dec 24 12:33:18 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .

Summary:
85bbf617bb WEB: Don't make the cache database depend on the hostname


Commit: 85bbf617bbabf8be41d58a8032b6320c7fefd272
    https://github.com/scummvm/scummvm-web/commit/85bbf617bbabf8be41d58a8032b6320c7fefd272
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-12-24T13:31:11+01:00

Commit Message:
WEB: Don't make the cache database depend on the hostname

This avoids having two caches when accessing the website with or without
a www and this is also more robust.
Make use of the DEV_SERVER constant and allow to enable it by setting an
environment variable.

Changed paths:
    include/Models/BasicModel.php
    public_html/index.php


diff --git a/include/Models/BasicModel.php b/include/Models/BasicModel.php
index 50a751e7..2dbfe8a1 100644
--- a/include/Models/BasicModel.php
+++ b/include/Models/BasicModel.php
@@ -17,7 +17,7 @@ abstract class BasicModel
         if (is_null(self::$cache)) {
             try {
                 $driver = extension_loaded('redis') ? 'redis' : 'predis';
-                $database = $_SERVER['HTTP_HOST'] === 'www.scummvm.org' ? 8 : 7;
+                $database = DEV_SERVER ? 7 : 8;
                 $config = extension_loaded('redis')
                     ? new RedisConfig(['database' => $database])
                     : new PredisConfig(['database' => $database]);
diff --git a/public_html/index.php b/public_html/index.php
index 38ecd393..f12f3738 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -5,14 +5,22 @@ namespace ScummVM;
  * Development only
  * Don't re-route static file requests to index.php
  * And change directory context to public_html
+ *
+ * When DEV_SERVER is true a different Redis database is chosen
+ * It's true when running using PHP built-in server or
+ * if the DEV_SERVER environment variable is set to 1
  */
 if (isset($_SERVER['SERVER_SOFTWARE']) &&
-\preg_match("/PHP [\d\.]+ Development Server/",$_SERVER['SERVER_SOFTWARE'])) {
-  chdir('public_html');
+    \preg_match("/PHP [\d\.]+ Development Server/",$_SERVER['SERVER_SOFTWARE'])) {
   define('DEV_SERVER', true);
+  chdir('public_html');
   if (\preg_match('/\.(?:png|jpg|jpeg|gif|css|js|svg)/', $_SERVER["REQUEST_URI"])) {
     return false;
   }
+} else if (getenv('DEV_SERVER') === "1") {
+  define('DEV_SERVER', true);
+} else {
+  define('DEV_SERVER', false);
 }
 
 require_once __DIR__ . '/../vendor/autoload.php';




More information about the Scummvm-git-logs mailing list