8000 Undefined variable: exitCode in vendor/symfony/console/Application.php on line 886 · Issue #25872 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Undefined variable: exitCode in vendor/symfony/console/Application.php on line 886 #25872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
axzx opened this issue Jan 21, 2018 · 8 comments
Closed

Comments

@axzx
Copy link
Contributor
axzx commented Jan 21, 2018
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.3

PHP 7.1.13-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jan 5 2018 13:26:45) ( NTS )
env=prod

./bin/console c:cl

PHP Notice:  Undefined variable: exitCode in vendor/symfony/console/Application.php on line 886

In ConsoleTerminateEvent.php line 27:
                                                                                                                                                     
  Type error: Argument 4 passed to Symfony\Component\Console\Event\ConsoleTerminateEvent::__construct() must be of the type integer, null given, ca  
  lled in vendor/symfony/console/Application.php on line 886                                                                           
                                                                                                                                                     

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

Reproduction

run:

composer create-project symfony/skeleton demo
cd demo
composer req mailer debug

edit .env

APP_ENV=prod

edit config/packages/prod/monolog.yaml

monolog:
    handlers:
        mail:
            type:         fingers_crossed
            action_level: critical
            handler:      deduplicated
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%env(EMAIL_SENDER)%'
            to_email:   '%env(EMAIL_RECIPIENT)%'
            subject:    'Error %env(ROUTER_HOST)%'
            level:      debug
            formatter:  monolog.formatter.html
            content_type: text/html

run:

rm -rf var/cache/prod
./bin/console c:cl
@nicolas-grekas
Copy link
Member

Can you share a reproducer or debug the situation? looking at the code in Application.php, I'm missing how this can happen.

@axzx
Copy link
Contributor Author
axzx commented Jan 21, 2018

config/packages/prod/monolog.yaml

monolog:
    handlers:
        mail:
            type:         fingers_crossed
            # 500 errors are logged at the critical level
            action_level: critical
            # to also log 400 level errors (but not 404's):
            # action_level: error
            # excluded_404s:
            #     - ^/
            handler:      deduplicated
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%env(EMAIL_SENDER)%'
            to_email:   '%env(EMAIL_RECIPIENT)%'

But on production, in file .env the variable EMAIL_RECIPIENT does not exist.
When I run the command cache:clear I get this message.

@nicolas-grekas
Copy link
Member

Sorry, that's not enough to reproduce the issue on my side.

@axzx
Copy link
Contributor Author
axzx commented Jan 21, 2018

file .env:

APP_ENV=prod
# EMAIL_RECIPIENT=email@localhost

file config/packages/prod/monolog.yaml:

monolog:
    handlers:
        mail:
            type:         fingers_crossed
            action_level: critical
            handler:      deduplicated
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%env(EMAIL_SENDER)%'
            to_email:   '%env(EMAIL_RECIPIENT)%'
            subject:    'Error %env(ROUTER_HOST)%'
            level:      debug
            formatter:  monolog.formatter.html
            content_type: text/html

run rm -rf var/cache/prod; ./bin/console c:cl

@theofidry
Copy link
Contributor
theofidry commented Jan 21, 2018

Could you create a public repo on which can reproduce the issue? That would help to both narrow down the issue and avoid going back and forth

@nicolas-grekas
Copy link
Member
composer create-project "symfony/skeleton" demo
cd demo
composer req log
# edit .env as above
# edit config/packages/prod/monolog.yaml
rm -rf var/cache/prod; ./bin/console c:cl

=> The service "monolog.handler.swift.mail_message_factory" has a dependency o
n a non-existent service "mailer".

No notice.

@axzx
Copy link
Contributor Author
axzx commented Jan 21, 2018

@nicolas-grekas

composer create-project symfony/skeleton demo
cd demo
composer req mailer debug
# edit .env as above
# edit config/packages/prod/monolog.yaml
rm -rf var/cache/prod; ./bin/console c:cl

@nicolas-grekas
Copy link
Member

Works thanks, fixed in #25873

chalasr pushed a commit that referenced this issue Jan 21, 2018
…(nicolas-grekas)

This PR was merged into the 4.0 branch.

Discussion
----------

[Console] Fix using finally where the catch can also fail

| Q             | A
| ------------- | ---
| Branch?       | 4.0
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25872
| License       | MIT
| Doc PR        | -

Restores code to 3.4 state, which is free from the issue.

Commits
-------

763a914 [Console] Fix using finally where the catch can also fail
@chalasr chalasr closed this as completed Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0