When I add a new custom link, it replaces one old link. The link ID is stuck at 1000. In the xmlsitemap table, it turns out when the real max value of id is 1234, MAX(id) returns 999 because the id field is of type varchar.

Patch to come.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio created an issue. See original summary.

jcisio’s picture

This patch adds a condition on "type" to make sure that id is always numeric, and cast the id column into numeric.

jcisio’s picture

Issue summary: View changes
leecjus’s picture

I am having the same problem detailed above and would like to apply the patch. I would appreciate any guidance as to how to deploy the patched code as I am not a skilled coder. Thank you in advance.

ChristianAdamski’s picture

@leecjus:

Open the file xmlsitemap_custom/src/Form/XmlSitemapCustomAddForm.php and replace the lines (roughly at line 90)

-    $query->addExpression('MAX(id)');
-    $id = $query->execute()->fetchField();

with these ones

+    $query->addExpression('MAX(CAST(id AS UNSIGNED))');
+    $query->condition('type', 'custom');
+    $id = (int) $query->execute()->fetchField();

then test if this works out locally and when it does, push the file to your stage/live system.

leecjus’s picture

Works great! Thank you very much for the straight forward instructions.

amateescu’s picture

The patch looks mostly ok, but we need to take into account the differences in data types for various database engines.

  • amateescu committed f53fb14 on 8.x-1.x authored by jcisio
    Issue #2735127 by amateescu, jcisio: New custom link replacing old one
    
amateescu’s picture

Status: Needs review » Fixed

Committed to 8.x-1.x. Thanks!

The last submitted patch, 2: xmlsitemap-2735127-1.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 7: 2735127-7.patch, failed testing.

The last submitted patch, 2: xmlsitemap-2735127-1.patch, failed testing.

The last submitted patch, 2: xmlsitemap-2735127-1.patch, failed testing.

The last submitted patch, 7: 2735127-7.patch, failed testing.

amateescu’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

Dave Reid’s picture

Version: 8.x-1.x-dev » 7.x-2.x-dev
Status: Closed (fixed) » Patch (to be ported)

Looks like we also need to fix this in D7.