-
Notifications
You must be signed in to change notification settings - Fork 340
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
500 Error when saving categories with invalid layout update xml - Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Call to a member function getCategorySearchQuery() on array #1347
Comments
We are encountering the same issue after using ElasticSuite. |
Im not gonna pretend like a fully know what is going on here but I changed the category object temporarily to pull the category from repo rather than the $category object currently used and my actual error was shown I believe. Smile\ElasticsuiteCatalog\Plugin\Ui\Category\Form\DataProviderPlugin
Maybe Magento changed validation with the layout update xml there as was not witnessing errors on previous versions however.... Some error checking is failing when this module is in place that stopped me from seeing the actual error about the layout update xml being invalid. My issue: Categories with Layout Update XML that is incorrect seem to throw a 500 error rather than showing an actual error. In my case:
My XML was:
I changed the Layout Update XML to below:
Category seems to save ok now once changed that Layout Update XML to be correct. @martijnrmediact maybe check your XML for something like that or try the little mod I did temporarily to get the actual error. |
Most probably a duplicate of #1345 Do you have any third-party or custom modules that are actually extending/overriding the legacy Category module ? |
I have had a look and cannot see anything that is extending or overriding |
This is my trace I cannot see anything other than elasticsearch and legacy magento code in there:
|
I'm having the same issue, very strange. If I comment the following code in Smile\ElasticsuiteCatalog\Plugin\Ui\Category\Form\DataProviderPlugin, it works ` /**
|
Ok, I took some time on this one. My mistake, I did not understand previously the things related to submitting an invalid layout update. So : NOT reproduced on Magento 2.3 BUT I reproduce it exactly on Magento 2.2.x So most probably, something has changed Magento side to better deal with these sort of errors. I'll see if we can provide a quickfix into Elasticsuite 2.6.x version. Probably the category don't get proper reload on such failure case. Regards |
Thanks Romain! I got myself out of trouble here but would be good to get an official fix rather than loading category from repo that I have done to fix this category not loading properly when errors shown. |
Erratum : reproduced in Elasticsuite 2.6.x AND 2.7.x. Appears to be due to the fact that when the form contains an error, previous data is set back to the current category as an array for the "virtual_rule" field, which causes this error. Will dig more on this one. Regards |
Fixed by PR #1355 |
Some categories throw 500 error upon saving from admin:
[11-Mar-2019 16:45:56 UTC] PHP Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Call to a member function getCategorySearchQuery() on array in /home/sites/magento/testing_html/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0
I have seen similar issues listed however flat category does not make a difference in this instance and feel they may have been on older versions and later fixed.
Preconditions
Magento Version : CE 2.2.7
ElasticSuite Version : "smile/elasticsuite": "^2.6.0"
Environment : Developer
Steps to reproduce
Expected result
Further debugging shows that the error seems to occur in
Smile\ElasticsuiteCatalog\Plugin\Ui\Category\Form\DataProviderPlugin
where on save of categories on my testing site thegetCategoryFilterParam()
method seems to cause this at$category->getVirtualRule()->getCategorySearchQuery($category); dump($category->getVirtualRule());
showing completely different results on different instances.dump($category->getVirtualRule(), true); shows:
Which is not correct looking at the same results on admin category page load and when saving on my working instances:
Seems similar to following issues:
#187
#205
The text was updated successfully, but these errors were encountered: