danielbrendel / hortusfox-web

Self-hosted collaborative plant management and tracking system for plant enthusiasts
https://www.hortusfox.com
MIT License
673 stars 34 forks source link

Docker: Deprecated: htmlspecialchars() error on login page #150

Closed tony-butchart closed 7 months ago

tony-butchart commented 8 months ago

Hi,

On a fresh deployment using the provided docker-compose file (with some tweaks, full stack below) I'm getting the following text in large font on the login page:

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/vendor/danielbrendel/asatru-php-framework/src/view.php(416) : eval()'d code on line 28

image

This error is also seen on the nav bar at the top after login.

I've just run with the defaults in the compose file with a couple of tweaks on the passwords and the volumes, let me know if I'm missing anything critical here:

version: "3.8"
services:
  app:
    container_name: hortusfox
    image: ghcr.io/danielbrendel/hortusfox-web:latest
    ports:
      - "8086:80"
    volumes:
      - hortusfox_app_images:/var/www/html/public/img
      - hortusfox_app_logs:/var/www/html/app/logs
      - hortusfox_app_backup:/var/www/html/public/backup
      - hortusfox_app_themes:/var/www/html/public/themes
      - hortusfox_app_migrate:/var/www/html/app/migrations
    env_file:
      - stack.env
    depends_on:
      - db

  db:
    container_name: hortusfox_db
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: blank
      MYSQL_DATABASE: hortusfox
      MYSQL_USER: user
      MYSQL_PASSWORD: blank
    ports:
      - "3306:3306"
    volumes:
      - hortusfox_db_data:/var/lib/mysql

volumes:
  hortusfox_db_data:
  hortusfox_app_images:
  hortusfox_app_logs:
  hortusfox_app_backup:
  hortusfox_app_themes:
  hortusfox_app_migrate:

.env file:

APP_ADMIN_EMAIL="blank@blank.com"
APP_ADMIN_PASSWORD="blank"
APP_BASE_DIR=""
APP_DEBUG="true"
APP_LANG="en"
APP_WORKSPACE="Home"
APP_ENABLE_SCROLLER="true"
APP_OVERLAY_ALPHA="null"
APP_ENABLE_CHAT="true"
APP_ONLINE_MINUTE_LIMIT=5
APP_SHOW_CHAT_ONLINE_USERS="false"
APP_SHOW_CHAT_TYPING_INDICATOR="false"
APP_ENABLE_SYSTEM_MESSAGES="true"
APP_OVERDUE_TASK_HOURS=10
APP_CRON_PW="test"
APP_CRON_MAIL_LIMIT=5
APP_ENABLE_HISTORY="true"
APP_HISTORY_NAME="History"
APP_ENABLE_PHOTO_SHARE="false"
PHOTO_RESIZE_FACTOR_DEFAULT=1.0
PHOTO_RESIZE_FACTOR_1=0.5
PHOTO_RESIZE_FACTOR_2=0.4
PHOTO_RESIZE_FACTOR_3=0.4
PHOTO_RESIZE_FACTOR_4=0.3
PHOTO_RESIZE_FACTOR_5=0.2
DB_HOST=hortusfox_db
DB_PORT=3306
DB_DATABASE=hortusfox
DB_USERNAME=root
DB_PASSWORD=blank
DB_CHARSET="utf8mb4"
LOG_ENABLE="true"
APP_NAME=HortusFox
tony-butchart commented 8 months ago

Some additional testing by bringing up the default docker-compose file shows the app works fine, working backwards from there to my changes to the environmental variables identified that removal of the following variables caused this issue for me:

      SMTP_FROMNAME: "Test"
      SMTP_FROMADDRESS: "test@domain.tld"
      SMTP_HOST: ""
      SMTP_PORT: 587
      SMTP_USERNAME: ""
      SMTP_PASSWORD: ""
      SMTP_ENCRYPTION: tls

I wasn't aware of the dependency for SMTP config and had no need for it yet so left it out, adding it back in (as above) resolved my issue.

Happy for this to be closed out if it's not viewed as an issue.

EricReiche commented 8 months ago

I would say it is unexpected behavior that the app does not fall back to default environment values. In a similar matter, the app breaks with error 500 if I leave out DB_PORT or DB_CHARSET.

danielbrendel commented 8 months ago

Due to the migration of some of the settings, we can remove some of the env vars from the docker-compose file. But some are mandatory. Yes, we can set default values at a different place. I'll think about what's the best approach here. I guess this is a good way, because this is actually the most encountered bug so far and it happens when people remove some stuff from the docker-compose file.

danielbrendel commented 8 months ago

To-do: Default also SMTP settings, because they can also be set up later in the admin dashboard.

danielbrendel commented 7 months ago

Resolved.