8000 Notice: Array to string conversion instead of informative error message when configuration with non-existent Doctrine connection is found in RegisterEventListenersAndSubscribersPass · Issue #27811 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Notice: Array to string conversion instead of informative error message when configuration with non-existent Doctrine connection is found in RegisterEventListenersAndSubscribersPass #27811

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
kalifg opened this issue Jul 2, 2018 · 2 comments

Comments

@kalifg
Copy link
kalifg commented Jul 2, 2018

Symfony version(s) affected: 3.4.11

Description
There is a small bug in an exception thrown by RegisterEventListenersAndSubscribersPass when a Doctrine connection that doesn't exist is referenced in configuration. Instead of getting the helpful exception message:

The Doctrine connection "root" referenced in service "stof_doctrine_extensions.listener.sluggable" does not exist. Available connections names: default

You instead get

Notice: Array to string conversion

How to reproduce
I was able to reproduce this by having the following configuration:

stof_doctrine_extensions:
    orm:
        root:
            sluggable: true
            timestampable: true

after I removed the connection named root.

Possible Solution
The variable $taggedSubscriber here is actually an array, with the name of the service as the first member. Changing the reference to $taggedSubscriber[0] should fix this.

https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php#L72

Additional context

@chalasr
Copy link
Member
chalasr commented Jul 3, 2018

👍 The sprintf() should use $id (from https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php#L68).
Can you submit a PR? It should target branch 2.8, bug also exists there.

@chalasr
Copy link
Member
chalasr commented Jul 3, 2018

See #27813

fabpot added a commit that referenced this issue Jul 3, 2018
…ged subscriber is invalid (stloyd)

This PR was merged into the 2.8 branch.

Discussion
----------

[Doctrine Bridge] Fixed usage of wrong variable when tagged subscriber is invalid

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27811
| License       | MIT

This change prevents error when invalid subscriber is being used.

Expected result:
```
The Doctrine connection "root" referenced in service "stof_doctrine_extensions.listener.sluggable" does not exist. Available connections names: default
```

Actual error:
```
Notice: Array to string conversion
```

Commits
-------

cf1bc66 [Doctrine Bridge] Fixed usage of wrong variable when tagged subscriber is invalid
@fabpot fabpot closed this as completed Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0