From 3de9fa24dd133d55731bee75bb790e677b63b4c6 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 31 Mar 2024 23:10:07 +0200 Subject: [PATCH] template.php install.php: handle cache directory being a symlink --- inc/template.php | 6 ++++-- install.php | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/inc/template.php b/inc/template.php index 11e74b7c..26ba6cc0 100644 --- a/inc/template.php +++ b/inc/template.php @@ -11,12 +11,14 @@ $twig = false; function load_twig() { global $twig, $config; + $cache_dir = "{$config['dir']['template']}/cache/"; + $loader = new Twig\Loader\FilesystemLoader($config['dir']['template']); $loader->setPaths($config['dir']['template']); $twig = new Twig\Environment($loader, array( 'autoescape' => false, - 'cache' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')) ? - new Twig_Cache_TinyboardFilesystem("{$config['dir']['template']}/cache") : false, + 'cache' => is_writable('templates/') || (is_dir($cache_dir) && is_writable($cache_dir)) ? + new Twig_Cache_TinyboardFilesystem($cache_dir) : false, 'debug' => $config['debug'], 'auto_reload' => $config['twig_auto_reload'] )); diff --git a/install.php b/install.php index c174771b..cb2a44cd 100644 --- a/install.php +++ b/install.php @@ -856,14 +856,14 @@ if ($step == 0) { array( 'category' => 'File permissions', 'name' => getcwd() . '/templates/cache', - 'result' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')), + 'result' => is_dir('templates/cache/') && is_writable('templates/cache/'), 'required' => true, 'message' => 'You must give vichan permission to create (and write to) the templates/cache directory or performance will be drastically reduced.' ), array( 'category' => 'File permissions', 'name' => getcwd() . '/tmp/cache', - 'result' => is_dir('tmp/cache') && is_writable('tmp/cache'), + 'result' => is_dir('tmp/cache/') && is_writable('tmp/cache/'), 'required' => true, 'message' => 'You must give vichan permission to write to the tmp/cache directory.' ), @@ -1032,4 +1032,3 @@ if ($step == 0) { echo Element('page.html', $page); } -