diff --git a/app/helpers/UtilsHelper.php b/app/helpers/UtilsHelper.php index e6f9f61c5..9a31472ad 100644 --- a/app/helpers/UtilsHelper.php +++ b/app/helpers/UtilsHelper.php @@ -16,7 +16,7 @@ class Utils $log = new Logger('movim'); $log->pushHandler(new SyslogHandler('movim')); - $stream = new StreamHandler(LOG_PATH . '/errors.log'); + $stream = new StreamHandler(LOG_PATH_RESOLVED . '/errors.log'); $stream->setFormatter(new LineFormatter(null, null, true)); $log->pushHandler($stream); @@ -32,7 +32,7 @@ class Utils $log = new Logger('movim'); $log->pushHandler(new SyslogHandler('movim')); - $stream = new StreamHandler(LOG_PATH . '/info.log'); + $stream = new StreamHandler(LOG_PATH_RESOLVED . '/info.log'); $stream->setFormatter(new LineFormatter(null, null, true)); $log->pushHandler($stream); @@ -46,7 +46,7 @@ class Utils public static function debug($logs) { $log = new Logger('movim'); - $log->pushHandler(new StreamHandler(LOG_PATH . '/debug.log')); + $log->pushHandler(new StreamHandler(LOG_PATH_RESOLVED . '/debug.log')); if (is_array($logs)) { $log->debug('', $logs); } else { diff --git a/app/views/page.tpl b/app/views/page.tpl index 8df3cca43..dd16f3174 100644 --- a/app/views/page.tpl +++ b/app/views/page.tpl @@ -13,7 +13,7 @@ <%scripts%> diff --git a/app/widgets/Notif/Notif.php b/app/widgets/Notif/Notif.php index db47020b1..256aa6370 100644 --- a/app/widgets/Notif/Notif.php +++ b/app/widgets/Notif/Notif.php @@ -79,7 +79,7 @@ class Notif extends Base $webPush = null; if (Session::start()->get('session_down')) { - $keys = json_decode(file_get_contents(CACHE_PATH . 'vapid_keys.json')); + $keys = json_decode(file_get_contents(CACHE_PATH_RESOLVED . 'vapid_keys.json')); $webPush = new WebPush([ 'VAPID' => [ diff --git a/app/widgets/System/System.php b/app/widgets/System/System.php index 4bb69f917..fd32b1cbd 100644 --- a/app/widgets/System/System.php +++ b/app/widgets/System/System.php @@ -8,7 +8,7 @@ class System extends Base { header('Content-Type: application/javascript'); - $keys = json_decode(file_get_contents(CACHE_PATH . 'vapid_keys.json')); + $keys = json_decode(file_get_contents(CACHE_PATH_RESOLVED . 'vapid_keys.json')); $this->view->assign('base_host', BASE_HOST); $this->view->assign('base_uri', BASE_URI); diff --git a/src/Movim/Bootstrap.php b/src/Movim/Bootstrap.php index 979d7b146..598d829b7 100644 --- a/src/Movim/Bootstrap.php +++ b/src/Movim/Bootstrap.php @@ -51,7 +51,7 @@ class Bootstrap private function checkSystem() { - if (!file_exists(CACHE_PATH) && !@mkdir(CACHE_PATH)) { + if (!file_exists(CACHE_PATH_RESOLVED) && !@mkdir(CACHE_PATH_RESOLVED)) { throw new \Exception('Couldn’t create cache directory'); } @@ -59,7 +59,7 @@ class Bootstrap throw new \Exception('Couldn’t create public cache directory'); } - if (!file_exists(LOG_PATH) && !@mkdir(LOG_PATH)) { + if (!file_exists(LOG_PATH_RESOLVED) && !@mkdir(LOG_PATH_RESOLVED)) { throw new \Exception('Couldn’t create log directory'); } } @@ -92,15 +92,15 @@ class Bootstrap define('VIEWS_PATH', DOCUMENT_ROOT . '/app/views/'); define('WIDGETS_PATH', DOCUMENT_ROOT . '/app/widgets/'); - define('LOG_PATH', config('paths.log')); - define('CACHE_PATH', config('paths.cache')); + define('LOG_PATH_RESOLVED', config('paths.log')); + define('CACHE_PATH_RESOLVED', config('paths.cache')); define('MOVIM_SQL_DATE', 'Y-m-d H:i:s'); define('DEFAULT_PICTURE_FORMAT', 'webp'); define('DEFAULT_PICTURE_QUALITY', 95); - define('API_SOCKET', CACHE_PATH . 'socketapi.sock'); + define('API_SOCKET', CACHE_PATH_RESOLVED . 'socketapi.sock'); } private function getVersion() diff --git a/src/Movim/Console/DaemonCommand.php b/src/Movim/Console/DaemonCommand.php index 32226eef1..ab6df891c 100644 --- a/src/Movim/Console/DaemonCommand.php +++ b/src/Movim/Console/DaemonCommand.php @@ -58,8 +58,8 @@ class DaemonCommand extends Command if (config('daemon.url') && Validator::url()->notEmpty()->validate(config('daemon.url'))) { $baseuri = rtrim(config('daemon.url'), '/') . '/'; - } elseif (file_exists(CACHE_PATH.'baseuri')) { - $baseuri = file_get_contents(CACHE_PATH.'baseuri'); + } elseif (file_exists(CACHE_PATH_RESOLVED.'baseuri')) { + $baseuri = file_get_contents(CACHE_PATH_RESOLVED.'baseuri'); } else { $output->writeln('Please load the login page once before starting the daemon to cache the public URL'); $output->writeln('or configure DAEMON_URL in .env'); diff --git a/src/Movim/Controller/Front.php b/src/Movim/Controller/Front.php index 326b53e07..4cac55aa7 100644 --- a/src/Movim/Controller/Front.php +++ b/src/Movim/Controller/Front.php @@ -76,7 +76,7 @@ class Front extends Base // Useful for the daemon if (php_sapi_name() != 'cli' && $request == 'login') { - file_put_contents(CACHE_PATH.'baseuri', BASE_URI); + file_put_contents(CACHE_PATH_RESOLVED.'baseuri', BASE_URI); } $c->name = $request; diff --git a/src/Movim/Daemon/Core.php b/src/Movim/Daemon/Core.php index e5ba66c57..a1236065a 100644 --- a/src/Movim/Daemon/Core.php +++ b/src/Movim/Daemon/Core.php @@ -41,8 +41,8 @@ class Core implements MessageComponentInterface DBSession::whereNotNull('id')->delete(); // API_SOCKET ? - if (file_exists(CACHE_PATH . 'socketapi.sock')) { - unlink(CACHE_PATH . 'socketapi.sock'); + if (file_exists(CACHE_PATH_RESOLVED . 'socketapi.sock')) { + unlink(CACHE_PATH_RESOLVED . 'socketapi.sock'); } array_map('unlink', array_merge( @@ -53,10 +53,10 @@ class Core implements MessageComponentInterface $this->registerCleaner(); // Generate Push Notification - if (!file_exists(CACHE_PATH . 'vapid_keys.json')) { + if (!file_exists(CACHE_PATH_RESOLVED . 'vapid_keys.json')) { echo colorize("Generate and store the Push Notification VAPID keys", 'green')."\n"; $keyset = VAPID::createVapidKeys(); - file_put_contents(CACHE_PATH . 'vapid_keys.json', json_encode($keyset)); + file_put_contents(CACHE_PATH_RESOLVED . 'vapid_keys.json', json_encode($keyset)); } } diff --git a/src/Movim/Template/Partial.php b/src/Movim/Template/Partial.php index 91fdb950a..ec7924bdc 100644 --- a/src/Movim/Template/Partial.php +++ b/src/Movim/Template/Partial.php @@ -18,7 +18,7 @@ class Partial extends Tpl { $this->objectConfigure([ 'tpl_dir' => APP_PATH.'widgets/'.$widget->getName().'/', - 'cache_dir' => CACHE_PATH, + 'cache_dir' => CACHE_PATH_RESOLVED, 'tpl_ext' => 'tpl', 'auto_escape' => true ]); @@ -50,7 +50,7 @@ class Partial extends Tpl } else { foreach ( glob( - CACHE_PATH. + CACHE_PATH_RESOLVED. sha1(User::me()->id) . '_' . $templateFilePath . @@ -76,6 +76,6 @@ class Partial extends Tpl private function resolvedCacheKey(string $templateFilePath, string $key): string { - return CACHE_PATH . sha1(User::me()->id) . '_' . $templateFilePath . '_' . cleanupId($key). $this->extension; + return CACHE_PATH_RESOLVED . sha1(User::me()->id) . '_' . $templateFilePath . '_' . cleanupId($key). $this->extension; } } diff --git a/src/Movim/Widget/Base.php b/src/Movim/Widget/Base.php index 2899e8fd2..ad15c3a93 100644 --- a/src/Movim/Widget/Base.php +++ b/src/Movim/Widget/Base.php @@ -74,7 +74,7 @@ class Base $config = [ 'tpl_dir' => $this->respath('', true), - 'cache_dir' => CACHE_PATH, + 'cache_dir' => CACHE_PATH_RESOLVED, 'tpl_ext' => 'tpl', 'auto_escape' => true ]; diff --git a/src/Movim/i18n/Locale.php b/src/Movim/i18n/Locale.php index bd732521c..570f557b2 100644 --- a/src/Movim/i18n/Locale.php +++ b/src/Movim/i18n/Locale.php @@ -13,7 +13,7 @@ class Locale public $language; public $hash = []; - private $iniCache = CACHE_PATH.'locales.ini.cache'; + private $iniCache = CACHE_PATH_RESOLVED.'locales.ini.cache'; private function __construct() { @@ -233,7 +233,7 @@ class Locale public function loadPo() { // Load from the cache - $cacheFile = CACHE_PATH . $this->language . '.po.cache'; + $cacheFile = CACHE_PATH_RESOLVED . $this->language . '.po.cache'; if (file_exists($cacheFile) && is_readable($cacheFile)) { include $cacheFile; $this->translations = $translations;