From c3e43617e4ec2718c22431a2ddd343d90d383f9a Mon Sep 17 00:00:00 2001 From: Varakh Date: Wed, 7 Aug 2019 17:34:39 +0200 Subject: [PATCH] Minor refactoring for 2.1.2 --- CHANGELOG.md | 4 ++++ README.md | 5 +++-- config/EnvConstants.php | 17 +++++++++++++++++ docker/Dockerfile | 7 +++---- public/index.php | 6 ++---- src/Util/BootstrapHelper.php | 21 ++++++++------------- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6891a..bc3cc42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.1.2 - 2019/08/07 +* Minor refactoring +* Update documentation + ## 2.1.1 - 2019/08/07 * Updated translation diff --git a/README.md b/README.md index bf8b48b..750ed23 100755 --- a/README.md +++ b/README.md @@ -37,8 +37,9 @@ you're using docker as deployment type. * Logs are saved in `/var/www/html/application/log` for docker containers. You should create a volume for this location if you're using docker as deployment type. -**Important**: Ensure that host binds have permissions set up properly. The user which is used in the docker container is `www-data` with -id `82`. If, e.g. logs are host bound, then execute `chown -R 82:82 host/path/to/log`. The same holds true for snapshots. +**Important**: Ensure that host binds have permissions set up properly. The user which is used in the docker container +is `www-data` with id `82`. If, e.g. logs are host bound, then execute `chown -R 82:82 host/path/to/log`. +The same holds true for snapshots. ### Usage with docker-compose The recommended way is to use docker-compose. The `network_mode = "host"` is required in order to show correct IP diff --git a/config/EnvConstants.php b/config/EnvConstants.php index 2273e51..5e06e57 100644 --- a/config/EnvConstants.php +++ b/config/EnvConstants.php @@ -64,4 +64,21 @@ class EnvConstants * Log level */ const LOG_LEVEL = "log_level"; + + /** + * Required attributes + */ + const ENV_REQUIRED = [ + EnvConstants::SITE_TITLE, + EnvConstants::SITE_LANGUAGE, + EnvConstants::SITE_DATE_FORMAT, + EnvConstants::THEME, + EnvConstants::THEME_CACHE, + EnvConstants::TEAMSPEAK_HOST, + EnvConstants::TEAMSPEAK_QUERY_PORT, + EnvConstants::TEAMSPEAK_USER, + EnvConstants::TEAMSPEAK_LOG_LINES, + EnvConstants::LOG_NAME, + EnvConstants::LOG_LEVEL + ]; } \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index a3a56f4..98c3c6d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,6 +7,9 @@ RUN apk add --no-cache git \ # adjust nginx COPY docker/default.conf /etc/nginx/conf.d/default.conf COPY docker/nginx.conf /etc/nginx/nginx.conf +RUN sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 1024M|g" /etc/php/7.3/php.ini \ + && sed -i "s|post_max_size = 8M|post_max_size = 1024M|g" /etc/php/7.3/php.ini \ + && sed -i "s|max_execution_time = 30|max_execution_time = 86400|g" /etc/php/7.3/php.ini # copy application and set permissions COPY config/ /var/www/html/application/config/ @@ -16,10 +19,6 @@ COPY src/ /var/www/html/application/src/ COPY composer.json /var/www/html/application/composer.json RUN mkdir -p /var/www/html/application/bin/ \ && mkdir -p /var/www/html/application/cache/ \ - && chmod -R 777 /var/www/html/application/data/ \ - && mkdir -p /var/www/html/application/log/ \ - && touch /var/www/html/application/log/application.log \ - && chmod 777 /var/www/html/application/log/application.log \ && chown -R www-data:www-data /var/www/html/application # initialize app diff --git a/public/index.php b/public/index.php index e1270e5..d602cd4 100644 --- a/public/index.php +++ b/public/index.php @@ -215,7 +215,7 @@ $container['notFoundHandler'] = function ($container) { $container['errorHandler'] = function ($container) { return function (Request $request, Response $response, $exception) use ($container) { - // handle all teamspeak exceptions with a flash message + // handle all TeamSpeak exceptions with a flash message if ($exception instanceof TSException) { $container->flash->addMessage('error', $exception->getMessage()); @@ -230,9 +230,7 @@ $container['errorHandler'] = function ($container) { 'content' => $exception->getMessage() ]); } - } - // all others are 500 - else { + } else { $container['logger']->error($container['translator']->trans('log.internal.application.error'), [ 'file' => $exception->getFile(), 'line' => $exception->getLine(), diff --git a/src/Util/BootstrapHelper.php b/src/Util/BootstrapHelper.php index 2ea011b..5c87287 100644 --- a/src/Util/BootstrapHelper.php +++ b/src/Util/BootstrapHelper.php @@ -1,6 +1,7 @@ load(); - $env->required([ - EnvConstants::SITE_TITLE, - EnvConstants::SITE_LANGUAGE, - EnvConstants::SITE_DATE_FORMAT, - EnvConstants::THEME, - EnvConstants::THEME_CACHE, - EnvConstants::TEAMSPEAK_HOST, - EnvConstants::TEAMSPEAK_QUERY_PORT, - EnvConstants::TEAMSPEAK_USER, - EnvConstants::TEAMSPEAK_LOG_LINES, - EnvConstants::LOG_NAME, - EnvConstants::LOG_LEVEL - ]); + + try { + $env->required(EnvConstants::ENV_REQUIRED); + } catch (ValidationException $e) { + die($e->getMessage()); + } + return $res; } else { die('No environment file found in ' . realpath($envFile));