-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Infinite Recursion when using fields with 'help' option #6142
Comments
@jtaylor100 Thanks for the report. So
Inside, you're using if (null !== $help) {
$this->admin->getFormFieldDescription($name)->setHelp($help);
} And IMHO, we have two strategy here:
In the RetrieveAutocompleteItemsAction.php, we can see the problem. private function retrieveFormFieldDescription(
AdminInterface $admin,
string $field
): FieldDescriptionInterface {
$admin->getFormFieldDescriptions(); // This is a "hack" to build the form
$fieldDescription = $admin->getFormFieldDescription($field); // We can now access to the fieldDescription
...
}
Instead of $this->admin->addFormFieldDescription($fieldName, $fieldDescription); And then if (null !== $help) {
$this->admin->getFormFieldDescription($name)->setHelp($help);
} We could try to write somthing like if (null !== $help) {
fieldDescription->setHelp($help);
}
$this->admin->addFormFieldDescription($fieldName, $fieldDescription); The first solution would need some works and some debate
The second solution is easier and could be considered as a quick fix ; do you want to try the PR ? |
Sure thing, please assign me. I will try out the second solution. |
This should be fixed in 3.69.1 but I still have problems (memory exhausted) with SonataPageBundle (page admin). Can you confirm that the fix is not working yet? The problem goes away if I comment https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Form/FormMapper.php#L260 so it's still related to form help, isn't it? |
I think you're right @gremo It's coming from here: Seems like it's really too risky to keep the IMHO, this PR could be the right way to fix the issue #6148, but we need to check if it breaks something else and how to fix it. As shown by the test https://github.com/sonata-project/SonataAdminBundle/blob/3.x/tests/Admin/AdminTest.php#L1809, the modelAdmin has no filterDescription when we try to access them without building the Datagrid. But it would make no sense to build it in the SonataAdminBundle/src/Action/RetrieveAutocompleteItemsAction.php Lines 187 to 189 in a9c1519
We maybe should replace the current |
@VincentLanglet thanks for the explanation, you are clearly more involved than me into this 👍 I'm working on a new porject and I need to get this fixed: I can downgrade sonata-admin, do you know which version is not affected (which commit break the help feature)? Thanks! |
@gremo For us the issues began with the upgrade from So I would downgrade to 3.68.0 and locking until the issue is resolved for you. And for the record, the fix in #6143 has fixed all our (@customer-alliance) regressions and we no longer experience any page loading issues. |
I agree, the risk of creating infinite loop was always here ; but the bug you found was added in 3.69.
It fixed the issue for SonataAdmin but not for SonataPage.
This is too easy for user to create infinite loop, that's why we need a long term fix. |
@jtaylor100 @VincentLanglet thank you both, i'll try to downgrade now. |
@jtaylor100 @gremo I think I have found a solution, If you want to take a look |
Environment
Sonata packages
Symfony packages
PHP version
Subject
After upgrading to v3.69.0, we started to experience
while requesting many of our sonata admin pages. Breaking with the debugger before this memory exhaustion occurred showed this stack trace, suggesting infinite recursion when trying to map form fields.
After commenting out the help options on our form fields, then the errors did not occur. Stepping through the code,
getFormFieldDescription
is only called if the 'help' option is included.Potentially related to #6104?
Steps to reproduce
Create an admin with a form element that has help text.
Expected results
Successful page load.
Actual results
Out of memory exceptions.
The text was updated successfully, but these errors were encountered: