-
Notifications
You must be signed in to change notification settings - Fork 9.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
Javascript error thrown from uiComponent 'notification_area' if messages are malformed #14937
Comments
I've been experiencing this exact problem this week (M2.2.1). I too am using a Wyomind extension. Your workaround at least allowed me to use the admin. |
Having the same issue, also have the Wyomind extension installed. Can confirm the above solution/workaround resolves the issue. |
The empty $content
(P.s i used a Wyomind extension as well) |
Hi @sdzhepa. Thank you for working on this issue.
|
Hi @quisse. Thank you for working on this issue.
|
Hi @sylvainraye. Thank you for your report.
The fix will be available with the upcoming 2.2.8 release. |
A javascript error is thrown from the uiComponent
notification_area
in Magento backend when the parameter$content
of the class\Magento\Ui\TemplateEngine\Xhtml\Result::wrapContent
is empty or false. As the parameter is provided, no PHP error is thrown and the parameter doesn't have a strict type likestring
.The javascript error blocks all others frontend behavior.
The
\Magento\Ui\TemplateEngine\Xhtml\Result::wrapContent
method return a requireJs dependency but cause of the empty/false value, javascript throw this error:The position 33 is the following javascript piece of code returned by the method
\Magento\Ui\TemplateEngine\Xhtml\Result::wrapContent
{"*": {"Magento_Ui/js/core/app": }}
Preconditions
Steps to reproduce
We discovered a third party module from Wyomind providing this issue because the notification message has the following content (see attachment) with a malformed UTF8 and
Expected result
Actual result
Js position 33 is:
{"*": {"Magento_Ui/js/core/app": }}
There is json_encode function called at
\Magento\Ui\TemplateEngine\Xhtml\Result::appendLayoutConfiguration
to encode the configuration in json, however in some cases it can return false if any issue happens. The functionjson_last_error_msg()
permits to determine what was the last error returned. In my case, it was aMalformed UTF-8 characters, possibly incorrectly encoded
issueSolution:
One of the solution is of course making sure that no error can happen in json_encode, however a platform like Magento support third parties extension and those may provide issue, it's important to reduce the fields of blocking issue. So, in the case of the notification_area, it's better to totally not display the notifications but inform at least the user that there is a blocking issue by displaying an error message in the notification area then they should contact the admin instead of blocking completely the backend cause of this javascript error.
As workaround, we did temporary the following into the method
\Magento\Ui\TemplateEngine\Xhtml\Result::wrapContent
The text was updated successfully, but these errors were encountered: