When you have menu_link entities enabled for simple_sitemap, and there is some menu items disabled, after enabling the module or generate sitemap with drush, it crash:

Error: Call to a member function isRouted() on null in Drupal\simple_sitemap\Batch\BatchUrlGenerator->generateBundleUrls() (line 132 of                                                                                                [error]
/var/www/ujaen.es/current/web/modules/contrib/simple_sitemap/src/Batch/BatchUrlGenerator.php).
Error: Call to a member function isRouted() on null in /var/www/ujaen.es/current/web/modules/contrib/simple_sitemap/src/Batch/BatchUrlGenerator.php on line 132
Error: Call to a member function isRouted() on null in Drupal\simple_sitemap\Batch\BatchUrlGenerator->generateBundleUrls() (line 132 of /var/www/ujaen.es/current/web/modules/contrib/simple_sitemap/src/Batch/BatchUrlGenerator.php).

After tracing the source code, I've found a logic problem in generateBundleUrls method of BatchUrlGenerator class.

Here you can see an use case about the need of using continue 2 instead continue in a switch sentende inside a loop. If you use continue, it works like break sentence. It's documented here.

This is the patch.

Thanks.

Comments

skuark created an issue. See original summary.

  • gbyte.co committed c62e136 on 8.x-2.x authored by skuark
    Issue #2811627 by skuark: Batch URL Generator fails when you have...
gbyte’s picture

Status: Active » Fixed

Good catch, thanks for the extensive issue description, that made it a breeze.

Status: Fixed » Closed (fixed)

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