Skip to content

PHP CLI timezone not set – MISP workers run in wrong timezone #413

@LSI-ZuagrastaWastl

Description

@LSI-ZuagrastaWastl

Summary

entrypoint_fpm.sh sets date.timezone only in /etc/php/*/fpm/php.ini, but not in /etc/php/*/cli/php.ini.

MISP background workers (e.g. CakePHP console commands) use the CLI SAPI and therefore ignore the FPM timezone config. As a result, all worker-generated timestamps use the container's default UTC regardless of the TZ environment variable.

I didn't notice this during my previous checks and tests, since I was manually triggering pulls and pushes, for example. However, it appears that the set time zone is indeed being used in those cases.

Steps to reproduce

  1. Set TZ to a time zone other than UTC, e.g.: TZ=Europe/Berlin in the container environment.
  2. Take a look in logs/misp-workers.log
  3. Observe that the logged time is UTC, not Europe/Berlin.

Expected behaviour

date.timezone in both fpm/php.ini and cli/php.ini reflects the TZ env var.

Fix

Add the following loop to change_php_vars() in entrypoint_fpm.sh:

for FILE in /etc/php/*/cli/php.ini; do
    [[ -e $FILE ]] || break
    sed -i "s|^;date.timezone =.*|date.timezone = ${TZ}|" "$FILE"
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions