Skip to content

Shopware cart.expire_days cannot be set through environment variables #18256

Description

Shopware Version

6.5.8.12

Affected area / extension

Platform(Default)

Actual behaviour

The configuration does not support the use of env-vars to define the expiry of neither shopware.cart.expire_days nor shopware.sales_channel_context.expire_days.

This hinders quick changes to these critical values and especially for PaaS will always require a code-change and re-deployment.

Expected behaviour

The env-var is accepted as value at compile time and only evaluated at runtime.

How to reproduce

Take the following configuration:

parameters:
  env(CART_EXPIRE_DAYS): 10

shopware:
  cart:
    expire_days: '%env(int:CART_EXPIRE_DAYS)%'

To reproduce the error below:

www-data@a671b715b4ff:~/html$ bin/console debug:config shopware cart
Symfony\Component\Config\Definition\Exception\InvalidConfigurationException^ {#27774
  #message: "The value 0 is too small for path "shopware.cart.expire_days". Should be greater than or equal to 1"
  #code: 0
  #file: "./vendor/symfony/config/Definition/NumericNode.php"
  #line: 45
  -path: "shopware.cart.expire_days"
  -containsHints: false
  trace: {
    ./vendor/symfony/config/Definition/NumericNode.php:45 { …}
    ./vendor/symfony/config/Definition/BaseNode.php:421 { …}
    ./vendor/symfony/config/Definition/BaseNode.php:410 { …}
    ./vendor/symfony/config/Definition/ArrayNode.php:252 { …}
    ./vendor/symfony/config/Definition/BaseNode.php:421 { …}
    ./vendor/symfony/config/Definition/ArrayNode.php:252 { …}
    ./vendor/symfony/config/Definition/BaseNode.php:421 { …}
    ./vendor/symfony/config/Definition/Processor.php:36 { …}
    ./vendor/symfony/config/Definition/Processor.php:46 { …}
    ./vendor/symfony/dependency-injection/Compiler/ValidateEnvPlaceholdersPass.php:77 { …}
    ./vendor/symfony/dependency-injection/Compiler/Compiler.php:80 { …}
    ./vendor/symfony/dependency-injection/ContainerBuilder.php:767 { …}
    ./vendor/symfony/http-kernel/Kernel.php:507 { …}
    ./vendor/shopware/core/Kernel.php:193 { …}
    ./bin/console:54 {
      {closure}^
      › $application = new Application($kernel);
      › $kernel->boot();
      › 
    }
    ./vendor/symfony/runtime/Resolver/DebugClosureResolver.php:25 { …}
    ./vendor/autoload_runtime.php:24 { …}
    ./bin/console:17 { …}
  }
}

This is caused by a comparison of the env-var default value 0 (zero) to the compile-time constraints defined for the bundle configuration.


Based on the code I also suspect that the following options do not support this as well:

  • shopware.sitemap.batchsize
  • shopware.dal.batch_size
  • shopware.dal.max_rule_prices
  • shopware.dal.versioning.expire_days
  • shopware.cart.expire_days
  • shopware.sales_channel_context.expire_days
  • As well as all config nodes added in later versions with min($v) where $v > 0.
    In the latest version there are 15 usages of min() in the Configuration.php file of Shopware Core.

The cause for this lies with Symfony itself and how it compiles the DI container. Symfony generally does not support mixing runtime and compile time parameters.

See also symfony/symfony#58878 (comment).

This means either the constraints on the config node(s) are removed or the node(s) should explicitly be marked to not support placeholders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform(Default)domain/frameworkResponsible for the framework-level code includes core, administration, storefront, and frontendspriority/lowItems that don't require immediate attention.qi/sw-triageTriggers the automated sw-triage agentic workflow on this issue.

    Type

    Fields

    Priority

    Low

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions