Commit 9cbfca97 authored by Kirill Semihin's avatar Kirill Semihin Committed by Oleksandr Dekhteruk
Browse files

Issue #2548647 by ksemihin, Lukas von Blarer, hswong3i, Jaapx, swentel,...

Issue #2548647 by ksemihin, Lukas von Blarer, hswong3i, Jaapx, swentel, remyyyyy, pifagor, alex_optim: Fatal error: Call to a member function getName() on a non-object
parent 51f9ed47
......@@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\core\Language\LanguageInterface;
* Provides a listing of XmlSitemap.
......@@ -84,7 +85,15 @@ class XmlSitemapListBuilder extends ConfigEntityListBuilder {
if ($this->moduleHandler->moduleExists('language')) {
if (isset($entity->context['language'])) {
$language = $this->languageManager->getLanguage($entity->context['language']);
$row['language'] = $language->getName();
// In some cases ::getLanguage() can return NULL value.
if (!is_null($language) && ($language instanceof LanguageInterface)) {
$row['language'] = $language->getName();
else {
\Drupal::logger('xmlsitemap')->error('Can\'t determine language for entity with @id', array('@id' => $entity->id()));
// Set as default row value.
$row['language'] = $this->t('Undefined');
else {
$row['language'] = $this->t('Undefined');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment