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
Autowired ParamConverter no longer working #29819
Comments
What is the error that you get? |
Unable to guess how to get a Doctrine instance from the request information
for parameter "post".
…On Tue, Jan 15, 2019 at 6:26 AM Christian Flothmann < ***@***.***> wrote:
What is the error that you get?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29819 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAl0QRJBnxdwFRB9l6ChgkojkIqeLq3Kks5vDbrugaJpZM4Z10eL>
.
|
I can demonstrate this error in the Symfony Demo:
Tests fail, the key issue is that PostParamConverter isn't being called. You can also see it with
Then open http://127.0.0.1:8000/en/blog/bug-posts/test-post-to-demonstrate-bug |
Thank you for investing time into this example that greatly allowed me to reproduce what you experience. However, this is the expected behaviour. If you do not add the /**
* @Route("/bug-posts/{postSlug}", methods={"GET"}, name="blog_post_bug")
* @ParamConverter("post", options={"mapping": {"postSlug": "slug"}})
*/
public function postShowBug(Post $post): Response
{
// ...
} I am closing here as there is nothing to fix. Thank you for understanding. |
I've finally (after far too many hours) found a simple test case that demonstrates the error. If I add this to composer.json's require section, it works:
So to see this in action: git clone git@github.com:survos/symfony-demo.git
cd symfony-demo
composer install
php vendor/bin/server:start
success: http://127.0.0.1:8000/en/blog/bug-posts/test-post-to-demonstrate-bug
git checkout di-bug
composer install
(I seem to need to clear the cache after this as well, even though composer install should do it).
fails: http://127.0.0.1:8000/en/blog/bug-posts/test-post-to-demonstrate-bug The only difference between the two is composer.json changing from:
to
And of course the "composer update" command to generate the lock file. |
Thank you for investing the time to investigate this a bit more and sorry for closing too early. I was under the impression that you used the param converters from the SensioFrameworkExtraBundle, but there is a custom param converter class which indeed does not work as expected anymore. |
Nope, that's not working. If you pull that repo, branch di-bug now
has "composer
require symfony/dependency-injection:~4.2@dev" and the error still exists.
You can run
vendor/codecept/run functional -f
works on master (with the older DI), fails on di-bug.
…On Wed, Jan 16, 2019 at 3:52 AM Christian Flothmann < ***@***.***> wrote:
There is good news though. This seems to be caused by the same as #29836
<#29836> which will be fixed in
4.2.3 since #29597 <#29597> was
reverted in #29853 <#29853>.
Can you confirm that running composer require
***@***.*** solves it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29819 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAl0QSe9xfzA3kiWEDygLxN7Y97LMrD5ks5vDuhqgaJpZM4Z10eL>
.
|
I see this error on both branches:
But this looks expected to me. The path used here matches the route pattern for the
|
Ah, I see. I over-hacked something during debugging. I'll test in
symfony-demo and also in my project and get back to you.
…On Wed, Jan 16, 2019 at 5:34 AM Christian Flothmann < ***@***.***> wrote:
I see this error on both branches:
$ php vendor/bin/codecept run -f
Codeception PHP Testing Framework v2.5.2
Powered by PHPUnit 7.5.2 by Sebastian Bergmann and contributors.
Running with seed:
App\Tests.acceptance Tests (2) -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing App\Tests.acceptance
✔ BlogCept: Open blog page and see article there (0.97s)
✔ LoginCept: Login as admin to backend (1.71s)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
App\Tests.functional Tests (14) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing App\Tests.functional
✖ PublicUrlsCept: Open public urls and see requested page (1.53s)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
App\Tests.unit Tests (25) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing App\Tests.unit
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 22.08 seconds, Memory: 52.25MB
There was 1 failure:
---------
1) PublicUrlsCept: Open public urls and see requested page
Test tests/functional/PublicUrlsCept.php
Step See response code is 200
Fail Expected HTTP Status Code: 200 (OK). Actual Status Code: 500 (Internal Server Error)
Failed asserting that 500 matches expected 200.
Scenario Steps:
3. $I->seeResponseCodeIs(200) at tests/functional/PublicUrlsCept.php:17
2. $I->amOnPage("/en/blog/posts/test-post-to-demonstrate-bug") at tests/functional/PublicUrlsCept.php:16
1. // As an Anonymous
FAILURES!
Tests: 3, Assertions: 7, Failures: 1.
But this looks expected to me. The path used here matches the route
pattern for the BlogController::postShow() method where the placeholder
is named slug and not postSlug and thus making your param converter fail
with this error:
Route attribute postSlug is missing
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29819 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAl0Qc6BO7nS_FBtWhYr9PKy_IR6zPu0ks5vDwBAgaJpZM4Z10eL>
.
|
I think the problem is having two converters, it seems reasonable that if
only one is automatically supported.
So it's working on symfony-demo, but failing on my app. I'll continue to
debug that, but yes, this seems to be fixed now.
Thanks!
Tac
…On Wed, Jan 16, 2019 at 5:36 AM Tac Tacelosky ***@***.***> wrote:
Ah, I see. I over-hacked something during debugging. I'll test in
symfony-demo and also in my project and get back to you.
On Wed, Jan 16, 2019 at 5:34 AM Christian Flothmann <
***@***.***> wrote:
> I see this error on both branches:
>
> $ php vendor/bin/codecept run -f
>
> Codeception PHP Testing Framework v2.5.2
>
> Powered by PHPUnit 7.5.2 by Sebastian Bergmann and contributors.
>
> Running with seed:
>
>
>
>
>
> App\Tests.acceptance Tests (2) -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Testing App\Tests.acceptance
>
> ✔ BlogCept: Open blog page and see article there (0.97s)
>
> ✔ LoginCept: Login as admin to backend (1.71s)
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
> App\Tests.functional Tests (14) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Testing App\Tests.functional
>
> ✖ PublicUrlsCept: Open public urls and see requested page (1.53s)
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
> App\Tests.unit Tests (25) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Testing App\Tests.unit
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
> Time: 22.08 seconds, Memory: 52.25MB
>
>
>
> There was 1 failure:
>
>
>
> ---------
>
> 1) PublicUrlsCept: Open public urls and see requested page
>
> Test tests/functional/PublicUrlsCept.php
>
> Step See response code is 200
>
> Fail Expected HTTP Status Code: 200 (OK). Actual Status Code: 500 (Internal Server Error)
>
> Failed asserting that 500 matches expected 200.
>
>
>
> Scenario Steps:
>
>
>
> 3. $I->seeResponseCodeIs(200) at tests/functional/PublicUrlsCept.php:17
>
> 2. $I->amOnPage("/en/blog/posts/test-post-to-demonstrate-bug") at tests/functional/PublicUrlsCept.php:16
>
> 1. // As an Anonymous
>
>
>
>
>
> FAILURES!
>
> Tests: 3, Assertions: 7, Failures: 1.
>
>
> But this looks expected to me. The path used here matches the route
> pattern for the BlogController::postShow() method where the placeholder
> is named slug and not postSlug and thus making your param converter fail
> with this error:
>
> Route attribute postSlug is missing
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#29819 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAl0Qc6BO7nS_FBtWhYr9PKy_IR6zPu0ks5vDwBAgaJpZM4Z10eL>
> .
>
|
Thank you for the confirmation. 👍 I am closing then. P.S.: Feel free to reach out at the Symfony Slack if you need to help with the implementation. |
Within my app it definitely doesn't work. I've made sure the cache is
cleared, etc., but toggling back and forth between the dev and the old one
with the commit hash, the dev doesn't work in my app. I have a dump() in
the ParamConverter code that isn't being called with the dev branch and is
with the old commit.
Happy to give you access, setup is pretty simple, thought the code itself
is not particularly clean. Or simply wait until the next version, since I can use the hash in composer.json for now. It was a complete show-stopper for us, since we use it all over the code.
|
Sure, if you can give me access, I can try to take a look at it tonight. |
Thanks. I'll play around with it a bit more and document the installation
part so you can see replicate it. I have jury duty today, so it'll be
several hours. What timezone are you in? I'm in DC (New York time, EST)
…On Wed, Jan 16, 2019 at 6:17 AM Christian Flothmann < ***@***.***> wrote:
Sure, if you can give me access, I can try to take a look at it tonight.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29819 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAl0QVz-aNTPha0GSvu00PTlZIOlNA-5ks5vDwo-gaJpZM4Z10eL>
.
|
CET |
@xabbuh When upgrading SensioFrameworkExtraBundle on an application using sf 3.4 paramconverter is broken. It seems that the faulty code was revert in 4.* but not in 3.* as you can see here : https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php#L37 Should I fill an new issue? |
Please do and please also provide a small example application that allows to reproduce. |
Symfony version(s) affected: 4.2.2
Description
I have a service that implements ParamConverterInterface that worked fine a few days ago, but when I run 'composer update', I can an error message that Doctrine cannot find the entity. This may be related to #29810
How to reproduce
I've attached my composer.json/lock
setup.zip
. Follow the instructions to create a ParamConverter. run composer install with my attached files. The controller should return a valid entity. Then run composer.update, now it will fail.
Sorry I can't provide a more precise way to reproduce this problem.
The text was updated successfully, but these errors were encountered: