8000 Environment Variables lack type - break built-in Symfony configuration · Issue #22151 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Environment Variables lack type - break built-in Symfony configuration #22151
Closed
@smcjones

Description

@smcjones
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.2

Related to #20434, if you try to pull data such as CACHE from an environment variable and pass it to Twig, Twig's Bundle reads the type literally, as "false" or "true" - as it is passed from getenv.

How to Replicate

Add this environment variable:

CACHE false

In config.yml:

twig:
    cache: %env(CACHE)%

This results in a cache being created under web/false/, which is certainly not the intended result.

Note that this has other unintended consequences throughout Symfony, where a boolean is expected but not validated.

Solutions?

A simple solution could be to use the env() library created by Laravel as it provides for type coercion out of the box.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0