Browse Source

Don't mix up DotEnv variable with internal ones

pull/1169/head
Timothée Jaussoin 3 years ago
parent
commit
3cc04a771f
  1. 6
      app/helpers/UtilsHelper.php
  2. 2
      app/views/page.tpl
  3. 2
      app/widgets/Notif/Notif.php
  4. 2
      app/widgets/System/System.php
  5. 10
      src/Movim/Bootstrap.php
  6. 4
      src/Movim/Console/DaemonCommand.php
  7. 2
      src/Movim/Controller/Front.php
  8. 8
      src/Movim/Daemon/Core.php
  9. 6
      src/Movim/Template/Partial.php
  10. 2
      src/Movim/Widget/Base.php
  11. 4
      src/Movim/i18n/Locale.php

6
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 {

2
app/views/page.tpl

@ -13,7 +13,7 @@
<script src="<?php echo
\Movim\Route::urlize('system') .
'&t=' .
filemtime(CACHE_PATH . 'socketapi.sock');
filemtime(CACHE_PATH_RESOLVED . 'socketapi.sock');
?>"></script>
<meta name="viewport" content="width=device-width, user-scalable=no">
<%scripts%>

2
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' => [

2
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);

10
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()

4
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('<comment>Please load the login page once before starting the daemon to cache the public URL</comment>');
$output->writeln('<comment>or configure DAEMON_URL in .env</comment>');

2
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;

8
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));
}
}

6
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;
}
}

2
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
];

4
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;

Loading…
Cancel
Save