File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
app/code/Magento/Eav/Model/Entity/Attribute/Backend Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function beforeSave($object)
41
41
{
42
42
// parent::beforeSave() is not called intentionally
43
43
$ attrCode = $ this ->getAttribute ()->getAttributeCode ();
44
- if ($ object ->hasData ($ attrCode ) && !$ this ->isJsonEncoded (( string ) $ object ->getData ($ attrCode ))) {
44
+ if ($ object ->hasData ($ attrCode ) && !$ this ->isJsonEncoded ($ object ->getData ($ attrCode ))) {
45
45
$ object ->setData ($ attrCode , $ this ->jsonSerializer ->serialize ($ object ->getData ($ attrCode )));
46
46
}
47
47
return $ this ;
@@ -65,16 +65,18 @@ public function afterLoad($object)
65
65
/**
66
66
* Returns true if given param is a valid json value else false.
67
67
*
68
- * @param string $value
68
+ * @param $value
69
69
* @return bool
70
70
*/
71
- private function isJsonEncoded (string $ value ): bool
71
+ private function isJsonEncoded ($ value ): bool
72
72
{
73
- $ result = true ;
74
- try {
75
- $ this ->jsonSerializer ->unserialize ($ value );
76
- } catch (\InvalidArgumentException $ e ) {
77
- $ result = false ;
73
+ $ result = is_string ($ value );
74
+ if ($ result ) {
75
+ try {
76
+ $ this ->jsonSerializer ->unserialize ($ value );
77
+ } catch (\InvalidArgumentException $ e ) {
78
+ $ result = false ;
79
+ }
78
80
}
79
81
80
82
return $ result ;
You can’t perform that action at this time.
0 commit comments