Tried submitting the same path twice and the validation did not catch the error. The UI shows both values and they are in the DB. This allows getting duplicates for a given path, which is totally undesirable.

Duplicates shown in the list of links, having different priorities and change frequencies.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jedihe’s picture

Status: Active » Needs review
FileSize
1.07 KB

Status: Needs review » Needs work

The last submitted patch, xmlsitemap-custom-disallow-duplicates-1999958--01.patch, failed testing.

Anonymous’s picture

Version: 7.x-2.0-rc2 » 7.x-2.x-dev
Status: Needs work » Needs review

Testbot needs -dev version?

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch, xmlsitemap-custom-disallow-duplicates-1999958--01.patch, failed testing.

Anonymous’s picture

Looking at the failures I think you'll need to update the tests with this patch as well.

jedihe’s picture

Status: Needs work » Needs review
FileSize
2.56 KB

Reworked patch.

jedihe’s picture

The patch also includes a new test case to ensure no duplicates can be added.

jedihe’s picture

Previous patch didn't cover the case for another link having the same id (using a different type than custom). Update attached.

giupenni’s picture

Issue summary: View changes

I have the same problems with 7.x-2.0.
Please fix it because is very huge for google!

jedihe’s picture

@giupenni: can you please test the patch and report back if it solves this issue for you? (remember to not test directly in your live site).

spidersilk’s picture

This problem is not restricted to XML sitemap custom - XML sitemap node and XML sitemap menu are quite capable of duplicating each other's links as well!

Maybe this patch could be adapted to prevent duplicate links from being added to the index no matter which submodule is adding them? It's not much use just having XML sitemap custom checking if a link is a duplicate before adding it, if the menu and node submodules are still duplicating each other's entries! And if it can be, then this support issue could be merged with #2257191: Remove duplicate links when using both menu and node sitemap, which is about duplicates caused by those two.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch in #9 to xmlsitemap_custom.admin.inc and xmlsitemap_custom.test does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap_custom/xmlsitemap_custom.admin.inc...
error: while searching for:
    $menu_item['access'] = FALSE;
  }

  if (db_query_range("SELECT 1 FROM {xmlsitemap} WHERE type <> 'custom' AND loc = :loc AND status = 1 AND access = 1 AND language IN (:languages)", 0, 1, array(':loc' => $link['loc'], ':languages' => array(LANGUAGE_NONE, $link['language'])))->fetchField()) {
    form_set_error('loc', t('There is already an existing link in the sitemap with the path %link.', array('%link' => $link['loc'])));
  }
  elseif (empty($menu_item['access']) && !is_readable('./' . $link['loc'])) {

error: patch failed: xmlsitemap_custom/xmlsitemap_custom.admin.inc:146
error: xmlsitemap_custom/xmlsitemap_custom.admin.inc: patch does not apply
Checking patch xmlsitemap_custom/xmlsitemap_custom.test...
error: while searching for:
    $this->assertText('The custom link for system/files was saved');
    $this->assertSitemapLinkValues('custom', $link['id'], array('priority' => 0.1, 'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS, 'access' => 1, 'status' => 1));

    $this->clickLink('Delete');
    $this->drupalPost(NULL, array(), t('Delete'));
    $this->assertText('The custom link for system/files has been deleted.');
    $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => 'system/files'));
  }

  /**

error: patch failed: xmlsitemap_custom/xmlsitemap_custom.test:68
error: xmlsitemap_custom/xmlsitemap_custom.test: patch does not apply