8000 Deprecated error are logged on production · Issue #26267 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Deprecated error are logged on production #26267
Closed
@soullivaneuh

Description

@soullivaneuh
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.4

I have a env.php file with the following line to set the error reporting level:

error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT);

This file is dumped on the composer autoload thanks to this configuration:

{
    "autoload": {
        "psr-4": { "": "src/" },
        "files": [
            "app/env.php",
            "app/AppKernel.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Dev\\": "src-dev",
            "Tests\\": "tests/"
        },
        "files": [
            "app/env_dev.php",
            "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
        ]
    },
}

And of course, the composer dump is called with --no-dev on the production server.

Currently, if a exception is thrown on production and deprecated error are triggered, they are logged on the production log file.

So I start with this tiny test:

require_once __DIR__.'/vendor/autoload.php';

var_dump(error_reporting());

trigger_error('This is a deprecation.', E_USER_DEPRECATED);
trigger_error('This is an error.', E_USER_ERROR);

And here is the result:

$ php current/test.php 
int(6143)
PHP Fatal error:  This is an error. in /var/www/project/prod/releases/20180221183905/test.php on line 10

It works. The deprecated error is ignored and the error_reporting value is 6143.

First, we can supposed the error_reporting is changed later. So I tried with this simple controller action:

public function failAction(): void
{
    trigger_error('Error reporting: '.error_reporting(), E_USER_DEPRECATED);
    throw new \Exception('Test exception with error reporting: '.error_reporting());
}

After a call of this action, I have the following log:

$ grep -B1 'Test exception' shared/var/logs/prod-2018-02.log 
[2018-02-22 11:16:37] php.INFO: User Deprecated: Error reporting: 6143 {"exception":"[object] (ErrorException(code: 0): User Deprecated: Error reporting: 6143 at /var/www/project/prod/releases/20180221183905/src/AppBundle/Controller/DefaultController.php:167)"} []
[2018-02-22 11:16:37] request.CRITICAL: Uncaught PHP Exception Exception: "Test exception with error reporting: 6143" at /var/www/project/prod/releases/20180221183905/src/AppBundle/Controller/DefaultController.php line 168 {"exception":"[object] (Exception(code: 0): Test exception with error reporting: 6143 at /var/www/project/prod/releases/20180221183905/src/AppBundle/Controller/DefaultController.php:168)"} []

As you can see, both deprecation and error are logged and the error_reporting value is still the same: 6143

This is why I'm thinking about a bug, because the error reporting level does not change so the deprecation should not be reported.

If you think it is not, I'm curious to know what is the issue. 😄

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

      0