Skip to content

[HttpCache] Undefined index trace_level when not in debug mode #32801

Closed
@dbu

Description

@dbu

Symfony version(s) affected: 4.3.3+ 9a2fcc9

Description
When running the HttpCache kernel with debug option false and no explicit trace_level, the default does not get initialized. The kernel still unconditionally calls addTraces.

How to reproduce
https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/tests/Unit/SymfonyCache/EventDispatchingHttpCacheTest.php
https://travis-ci.org/FriendsOfSymfony/FOSHttpCache/jobs/565046971

Possible Solution
Change this

if (!isset($options['trace_level']) && $this->options['debug']) {
$this->options['trace_level'] = 'full';
to

   if (!isset($options['trace_level'])) {
            $this->options['trace_level'] =  $this->options['debug'] ? 'full' : 'none';
   }

That code would actually match with the documentation on the parameter: "(default: 'full' if in debug; 'none' otherwise)"

Happy to write a pull request if you agree that this would be correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions