Error when use custom link with uncreated language prefix

Created on 10 August 2023, over 1 year ago

Problem/Motivation

When you added custom links in table of database with language prefix that didn't create on website, you will have fatal error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getName() on null in Drupal\xmlsitemap_custom\Controller\XmlSitemapCustomListController->render() (line 97 of modules/contrib/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php).
Drupal\xmlsitemap_custom\Controller\XmlSitemapCustomListController->render()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Install xmlsitemap module and enable xmlsitemap_custom submdule
Add to table DB xmlsitemap row with values for custom link and language prefix that not available on website (column language) OR Add custom link to some language by UI and then remove language from Drupal (it stay added custom link in DB).
Try to open tab Custom links of XML Sitemap configuration by UI
Get fatal Error: Call to a member function getName() on null in Drupal\xmlsitemap_custom\Controller\XmlSitemapCustomListController->render() (line 97 of modules/contrib/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php).

Proposed resolution

Add some check for existing languages in modules/contrib/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php.

πŸ› Bug report
Status

Needs review

Version

1.5

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024