When using translatable entities you get the following warning:

Illegal offset type in Drupal\language\ConfigurableLanguageManager->getFallbackCandidates()

This happens because the method "renderLeafletMarkers" within the class LeafletMarker in the file "leaflet/leaflet_views/src/Plugin/views/row/LeafletMarker.php" has a getViewBuilder->view method where the whole language object is inserted as a parameter. This is not correct due the fact that it should be the id of the language.

Anyhow, is it not better to get the translated entity on the query method itself of the view?

Patch will follow later.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

IJsbrandy created an issue. See original summary.

IJsbrandy’s picture

The patch

jwilson3’s picture

Status: Active » Reviewed & tested by the community

Work perfectly. Thanks.

jwilson3’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.21 KB
1.03 KB

I thought this was fixed but it turned up again, and I tracked the problem down to a very similar issue in LeafletMap.php, the fix in LeafletMarker.php on patch 2 is not enough to fix this.

Stack Trace:

Warning: Illegal offset type in Drupal\language\ConfigurableLanguageManager->getFallbackCandidates() (line 384 of core/modules/language/src/ConfigurableLanguageManager.php).
Drupal\language\ConfigurableLanguageManager->getFallbackCandidates(Array) (Line: 96)
Drupal\Core\Entity\EntityRepository->getTranslationFromContext(Object, Object, Array) (Line: 371)
Drupal\Core\Entity\EntityManager->getTranslationFromContext(Object, Object) (Line: 135)
Drupal\Core\Entity\EntityViewBuilder->viewMultiple(Array, 'tooltip', Object) (Line: 111)
Drupal\Core\Entity\EntityViewBuilder->view(Object, 'tooltip', Object) (Line: 421)
Drupal\leaflet_views\Plugin\views\style\LeafletMap->render(Array) (Line: 2105)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1519)

The problem is that LeafletMap on line 421 calls EntityViewBuilderInterface::view passing an object $entity->language() the third parameter, but it expects that to be a string $langcode.

Here is my one-line addition and accompanying interdiff.

jwilson3’s picture

FileSize
6.21 KB

Patch no longer applies. here is a reroll of #4.

  • itamair committed c0b5d8e on 8.x-1.x authored by jwilson3
    Issue #2891194 by jwilson3, IJsbrandy: Illegal offset type in Drupal\...
itamair’s picture

Status: Needs review » Fixed

  • itamair committed 155f469 on 8.x-1.x authored by IJsbrandy
    Issue #2891194 by jwilson3, IJsbrandy, itamair: Illegal offset type in...
jwilson3’s picture

Thanks for the second fix 155f469 to fix the $entity->language()->getId(). I missed that.

Status: Fixed » Closed (fixed)

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