Commit 6e434723 authored by gbyte.co's avatar gbyte.co

Issue #2816023: Unpublished translations are appearing in sitemap

parent 1c231627
......@@ -130,11 +130,6 @@ class BatchUrlGenerator {
continue;
}
// Do not include paths inaccessible to anonymous users.
if (!$url_object->access($this->anonUser)) {
continue;
}
$path = $url_object->getInternalPath();
// Do not include paths that have been already indexed.
......@@ -180,10 +175,6 @@ class BatchUrlGenerator {
}
$url_object = Url::fromUserInput($custom_path['path'], ['absolute' => TRUE]);
if (!$url_object->access($this->anonUser)) {
continue;
}
$path = $url_object->getInternalPath();
if ($this->batchInfo['remove_duplicates'] && $this->pathProcessed($path)) {
continue;
......@@ -283,22 +274,31 @@ class BatchUrlGenerator {
$translation_languages = !is_null($entity) && $this->batchInfo['skip_untranslated']
? $entity->getTranslationLanguages() : $this->languages;
// Entity is not translated.
if (!is_null($entity) && isset($translation_languages['und'])) {
$alternate_urls[$this->defaultLanguageId] = $url_object
->setOption('language', $this->languages[$this->defaultLanguageId])
->toString();
if ($url_object->access($this->anonUser)) {
$url_object->setOption('language', $this->languages[$this->defaultLanguageId]);
$alternate_urls[$this->defaultLanguageId] = $url_object->toString();
}
}
else {
foreach ($translation_languages as $language) {
// Including only translated variants of entity.
if (!is_null($entity) && $this->batchInfo['skip_untranslated']) {
foreach ($translation_languages as $language) {
$translation = $entity->getTranslation($language->getId());
if (!$translation->access('view')) {
continue;
if ($translation->access('view', $this->anonUser)) {
$url_object->setOption('language', $language);
$alternate_urls[$language->getId()] = $url_object->toString();
}
}
}
$alternate_urls[$language->getId()] = $url_object
->setOption('language', $language)
->toString();
// Not an entity or including all untranslated variants.
elseif ($url_object->access($this->anonUser)) {
foreach ($translation_languages as $language) {
$url_object->setOption('language', $language);
$alternate_urls[$language->getId()] = $url_object->toString();
}
}
}
......
Markdown is supported
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