From fdd3bfd105bece811a591a6ed7e4948ab56b2bde Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 17 Feb 2024 16:43:21 +0100 Subject: [PATCH] Fix config_lua reloading, cache clear problem --- system/functions.php | 3 ++- system/init.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/system/functions.php b/system/functions.php index 308919b8..bf8c8710 100644 --- a/system/functions.php +++ b/system/functions.php @@ -1226,7 +1226,8 @@ function clearCache() $configHighscoresPerPage = setting('core.highscores_per_page'); $skills = [POT::SKILL_FIST, POT::SKILL_CLUB, POT::SKILL_SWORD, POT::SKILL_AXE, POT::SKILL_DIST, POT::SKILL_SHIELD, POT::SKILL_FISH, POT::SKILL_LEVEL, POT::SKILL__MAGLEVEL, SKILL_FRAGS, SKILL_BALANCE]; foreach ($skills as $skill) { - $vocations = config('vocations') + ['all']; + // config('vocations') may be empty after previous cache clear + $vocations = (config('vocations') ?? []) + ['all']; foreach ($vocations as $vocation) { for($page = 0; $page < 10; $page++) { $cacheKey = 'highscores_' . $skill . '_' . strtolower($vocation) . '_' . $page . '_' . $configHighscoresPerPage; diff --git a/system/init.php b/system/init.php index ec61b459..10379b19 100644 --- a/system/init.php +++ b/system/init.php @@ -134,6 +134,10 @@ $ots = POT::getInstance(); $eloquentConnection = null; require_once SYSTEM . 'database.php'; +if ($config_lua_reload) { + clearCache(); +} + // verify myaac tables exists in database if(!defined('MYAAC_INSTALL') && !$db->hasTable('myaac_account_actions')) { throw new RuntimeException('Seems that the table myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting ' . BASE_URL . 'install');