I have a similar problem to the ones in the related issues:
Sitemaps generated with drush and cron (button and link) do not include published translated nodes when the default language node is unpublished.
When manually generating the sitemap via /admin/config/search/simplesitemap -> "Rebuild queue and generate" the translated nodes are included correctly.
I drilled it down to Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator->getDataSets() where the entityTypeManager query ($query->execute()) results in zero entities with drush and cron, and one entity when generating manually.
There are several nodes which disappear in the sitemap this way: each affected content type has only one node with several translations.

The nodes are accessible for anonymous user. Are drush and cron using a different context/user?

Setup: Drupal 8.8.1, PHP 7.2.26, Mysql 5.7.28

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sleitner created an issue. See original summary.

gbyte’s picture

Status: Active » Postponed (maintainer needs more info)

I tried to reproduce this in the past and failed in my environments. Can you please spin up a new Drupal instance and document a step-by-step reproducible way of getting this undesired result? I'll be happy to try and reproduce on my end and fix the bug. Alternatively if you can pinpoint the problem, feel free to submit a patch.

sleitner’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
734 bytes

It turns out that access permissions are checked twice.
First implicitly in Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator->getDataSets() when not specifying QueryInterface::accessCheck and second explicitly in Drupal\simple_sitemap\Plugin\simple_sitemap\EntityUrlGeneratorBase when checking $url_object->access .
This is a problem when you use a module which implements hook_node_access_records() and hook_node_grants() (e.g. node_view_permissions or node_view_language_permissions) in combination with drush or cron.

My suggestion is to not check the access in EntityUrlGenerator->getDataSets() and only check access in EntityUrlGeneratorBase

  • gbyte.co committed 9f04f3a on 8.x-3.x authored by sleitner
    Issue #3102450 by sleitner, gbyte.co: Manual generated sitemap differs...
gbyte’s picture

Status: Needs review » Fixed

Must have been hard to catch, thanks! Feel free to reopen this issue if you have any further suggestions.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.