Problem/Motivation

sitemap.xml is generated containing duplicated links.

To reproduce:
Case 1) e.g. enable sitemap generation to Basic Pages, then create nodes for this bundle. After that create menu links using the node paths created previously, like, node/1, node/2, etc. The sitemap will contain both links to same paths.

Case 2) e.g. enable sitemap generation to Basic Pages, then create nodes for this bundle. Create custom links using the same paths created previously.

Proposed resolution

Creates a mechanism to check duplicated entries before generate the xml. This mechanism needs to check the link priority too, If there are two entries for the same link, the higher priority value should be used.

I'll work to submit a patch to the next week.

Comments

jribeiro created an issue. See original summary.

gbyte’s picture

This shouldn't be a problem to fix, as before the sitemap gets generated, all links are put into a private variable in the SitemapGenerator class. Maybe instead of
$this->links = array_merge($this->links, $links);
there should be a call to a new private function like this:

private function add_links($links) {
  [Logic to remove links from $links which are already present in $this->links]
  ...
  $this->links = array_merge($this->links, $links);
}

Will take a look at it soon, but maybe you have a better idea ;)

  • gbyte.co committed cf9bab9 on 8.x-1.x
    Issue #2657232 by jribeiro, gbyte.co: Duplicated links
    
gbyte’s picture

Status: Active » Closed (fixed)

I simplified the plugin structure and implemented the duplicate check, however nothing fancy - no priorities are compared.
add_created_paths() is where you could implement some checking (priority/lastmod/path) before removing duplicates.