In certain conditions, the following error occurs while generating the sitemap at /sitemap.xml

Message	Notice: Undefined variable: context in Drupal\xmlsitemap\Controller\XmlSitemapController->renderSitemapXml() (line 76 of /var/www/project/web/modules/contrib/xmlsitemap/src/Controller/XmlSitemapController.php) 

This happens when I have the Enable developer mode to expose additional settings. Button checked. This button can be found in the Setting Tab -> Under Advanced Settings.

When I Uncheck the box and use the sitemap, it works fine.

Any ideas?

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

jonnyeom created an issue. See original summary.

rocket.man’s picture

Replaced undefined variable $context with $sitemap->getContext() method.

ytsurk’s picture

Works fine for me.

G42’s picture

I can not replicate this problem, have you tried the latest version?

alexandre.todorov’s picture

As the meaning of "current_context" is to get the current context, I think it is better to use xmlsitemap_get_current_context() which returns the currently active context and not the sitemap one. In fact it is intended to be the same than $sitemap->context because of $sitemap = XmlSitemap::loadByContext();