We're using this field as entity base field. Data are stored correctly, but formatter throws errors. It's because data property is not unserialised during the entity values load. We found similar issue in Geolocation module.

CommentFileSizeAuthor
#7 mapycz_bug.zip5.72 KBmirom
#2 3025966-2.patch809 bytesmirom

Comments

mirom created an issue. See original summary.

mirom’s picture

StatusFileSize
new809 bytes

Attached patch is inspired by Link module from the core and fixes the issue for us. We didn't notice any regressions described in the related geolocation issue.

mirom’s picture

Status: Active » Needs review
cvikir’s picture

Hello, can you tell us how to replicate the problem that is being fixed ?

marysmech’s picture

Status: Needs review » Postponed (maintainer needs more info)
cvikir’s picture

mirom’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new5.72 KB

Hi,
1) create a new custom entity type with "mapycz" base field
2) create a new entity of that entity type
3) see warnings in log

Warning: Illegal string offset 'center_lat' in Drupal\mapycz\Plugin\Field\FieldFormatter\MapyCzMapFormatter->viewElements() (line 112 of /app/web/modules/contrib/mapycz/src/Plugin/Field/FieldFormatter/MapyCzMapFormatter.php)
Warning: Illegal string offset 'center_lng' in Drupal\mapycz\Plugin\Field\FieldFormatter\MapyCzMapFormatter->viewElements() (line 113 of /app/web/modules/contrib/mapycz/src/Plugin/Field/FieldFormatter/MapyCzMapFormatter.php)
Warning: Illegal string offset 'zoom' in Drupal\mapycz\Plugin\Field\FieldFormatter\MapyCzMapFormatter->viewElements() (line 115 of /app/web/modules/contrib/mapycz/src/Plugin/Field/FieldFormatter/MapyCzMapFormatter.php)
Warning: Illegal string offset 'type' in Drupal\mapycz\Plugin\Field\FieldFormatter\MapyCzMapFormatter->viewElements() (line 116 of /app/web/modules/contrib/mapycz/src/Plugin/Field/FieldFormatter/MapyCzMapFormatter.php)
Warning: Illegal string offset 'type' in Drupal\mapycz\Plugin\Field\FieldFormatter\MapyCzMapFormatter->viewElements() (line 116 of /app/web/modules/contrib/mapycz/src/Plugin/Field/FieldFormatter/MapyCzMapFormatter.php)

4) map in not rendered on the entity detail page - error in browser console

Uncaught TypeError: Cannot read property 'enable' of undefined
    at String.<anonymous> (js_WBRPt_nJMFZtTPqMKb6tBFiN-PAluYcg4JWMtx1iHHI.js:89)
    at Function.each (js_RTAjp8eeIcx6FbTZvUHayBkzEYVmqPt5XM0LaKkeKPE.js:2)
    at Object.Drupal.mapycz.loadMaps (js_WBRPt_nJMFZtTPqMKb6tBFiN-PAluYcg4JWMtx1iHHI.js:65)
    at js_WBRPt_nJMFZtTPqMKb6tBFiN-PAluYcg4JWMtx1iHHI.js:53

I attach example code, where I'm able to replicate the error. Let me know if you think there is something wrong with my entity definition (Except a couple of lines generated via drush).

  • mirom committed 06a33c3 on 8.x-1.x
    Issue #3025966 by mirom: Data are not unserialised if field type is used...
mirom’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.