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