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
Fix menu in long-running process (RoadRunner, ReactPHP, Amphp) #7885
Conversation
In order to have new instance for every request in Long-running process (ReactPHP, Amphp, RoadRunner)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise menu is created once and then re-used - and that doesn't work if there is dynamic content in the menu.
@Warxcell Is there a way to add a test about the use-case which didn't work ?
@@ -33,6 +33,7 @@ | |||
]) | |||
|
|||
->set('sonata.admin.sidebar_menu', MenuItem::class) | |||
->share(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we cant add a test, we should at least leave a comment about why we do this, imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise menu is created once and then re-used - and that doesn't work if there is dynamic content in the menu.
@Warxcell Is there a way to add a test about the use-case which didn't work ?
Sure. Adding it atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. :)
phpunit.xml.dist
Outdated
@@ -33,5 +33,6 @@ It's auto-generated by sonata-project/dev-kit package. | |||
<php> | |||
<ini name="precision" value="8" /> | |||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" /> | |||
<env name="KERNEL_CLASS" value="Sonata\AdminBundle\Tests\App\AppKernel" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is autogenerated and cannot be touched.
Please add
protected static function getKernelClass(): string
{
return AppKernel::class;
}
instead in your MenuTest file if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Failure in PSALM seems unrelated 🤷 |
I'm on it |
public function testDynamicMenuInLongRunningProcess(): void | ||
{ | ||
$client = static::createClient(); | ||
$client->disableReboot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what makes the client share the same container? If yes, can you add a comment here to explain this line (ex: this ensures the container is reused across multiple request to simulate the behavior of ...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, adding
For psalm it's related to vimeo/psalm#8330 ; we will need to ignore the issue |
Thanks ! |
In order to have new instance for every request in Long-running process (ReactPHP, Amphp, RoadRunner).
Otherwise menu is created once and then re-used - and that doesn't work if there is dynamic content in the menu, since first request creates the menu and then all other requests uses the menu created by first request.
Subject
I am targeting this branch, because bugfix.
Changelog