From c34f02d916998603a8b7dcbd696e7a24a986c5e6 Mon Sep 17 00:00:00 2001
From: jo <ljonas@riseup.net>
Date: Wed, 1 Feb 2023 20:11:00 +0100
Subject: [PATCH] fix(legacy): improve error messages and logs

---
 legacy/application/common/CORSHelper.php               | 4 +++-
 legacy/application/configs/constants.php               | 1 +
 legacy/application/views/scripts/error/error-500.phtml | 7 ++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/legacy/application/common/CORSHelper.php b/legacy/application/common/CORSHelper.php
index b3c5ab2f6..d2de2bce1 100644
--- a/legacy/application/common/CORSHelper.php
+++ b/legacy/application/common/CORSHelper.php
@@ -10,7 +10,9 @@ class CORSHelper
 
         if (!($origin == '' || preg_match('/https?:\/\/localhost/', $origin) === 1 || in_array($origin, $allowedOrigins))) {
             // Don't allow CORS from other domains to prevent XSS.
-            Logging::error("request origin '{$origin}' is not in allowed '" . implode(', ', $allowedOrigins) . "'!");
+            Logging::error(
+                "request origin '{$origin}' is not in the configured 'allowed_cors_origins' '" . implode(', ', $allowedOrigins) . "'"
+            );
 
             throw new Zend_Controller_Action_Exception('Forbidden', 403);
         }
diff --git a/legacy/application/configs/constants.php b/legacy/application/configs/constants.php
index 68da43b2a..d09b6cfe0 100644
--- a/legacy/application/configs/constants.php
+++ b/legacy/application/configs/constants.php
@@ -41,6 +41,7 @@ define('WHOS_USING_URL', 'https://github.com/orgs/libretime/people');
 define('TERMS_AND_CONDITIONS_URL', 'https://github.com/libretime/libretime/blob/main/README.md');
 define('PRIVACY_POLICY_URL', 'https://github.com/libretime/organization/blob/main/CODE_OF_CONDUCT.md');
 define('USER_MANUAL_URL', 'https://libretime.org/docs');
+define('TROUBLESHOOTING_URL', 'https://libretime.org/docs/admin-manual/troubleshooting/');
 define('ABOUT_AIRTIME_URL', 'https://libretime.org');
 define('LIBRETIME_CONTRIBUTE_URL', 'https://libretime.org/contribute');
 define('LIBRETIME_DISCOURSE_URL', 'https://discourse.libretime.org');
diff --git a/legacy/application/views/scripts/error/error-500.phtml b/legacy/application/views/scripts/error/error-500.phtml
index 440bea27a..5b1682bcb 100644
--- a/legacy/application/views/scripts/error/error-500.phtml
+++ b/legacy/application/views/scripts/error/error-500.phtml
@@ -12,7 +12,12 @@
         <h2><?php echo _("Oops!") ?></h2>
         <p><?php echo _("Something went wrong!") ?></p>
         <div class="button-bar">
-            <a class="toggle-button" href="<?php echo $this->helpUrl; ?>"><?php echo _("Help") ?></a>
+            <a class="toggle-button" href="<?php echo TROUBLESHOOTING_URL; ?>" target="_blank">
+                <?php echo _("Troubleshooting help") ?>
+            </a>
+            <a class="toggle-button" href="<?php echo $this->helpUrl; ?>" target="_blank">
+                <?php echo _("More help") ?>
+            </a>
         </div>
     </div>
 </body>