Dolphiq / craft3-plugin-sitemap

A craft 3 plugin that provides an easy way to enable and manage an XML sitemap for search engines like Google
MIT License
28 stars 18 forks source link

Updating a category can yield an invalid project config which errors when running a migration #60

Open joepagan opened 3 years ago

joepagan commented 3 years ago

Hey, just found that if I update a category, removing an existing uriFormat, the project config files will update as follows:

+++ b/craft/config/project/categoryGroups/sectors--fdd1be2c-d545-4af2-9d6a-3a1bb2082e31.yaml
@@ -291,9 +291,9 @@ handle: sectors
 name: Sectors
 siteSettings:
   146e7a6b-f0ca-4f39-ba5d-d9eb009fc426: # UDL (en-GB)
-    hasUrls: true
-    template: sectors/_category
-    uriFormat: '{% if object.level == 1 %}sectors/{slug}{% else %}{parent.uri}/{slug}{% endif %}'
+    hasUrls: false
+    template: null
+    uriFormat: null
 structure:
   maxLevels: null
   uid: 0cc96d4e-d9ac-4f49-bc9d-db9e145926de
diff --git a/craft/config/project/dolphiq_sitemap_entries/1d8dd907-afd2-411d-a45b-3e213f5ff8fe.yaml b/craft/config/project/dolphiq_sitemap_entries/1d8dd907-afd2-411d-a45b-3e213f5ff8fe.yaml
index b8d2cce2..13a98673 100644
--- a/craft/config/project/dolphiq_sitemap_entries/1d8dd907-afd2-411d-a45b-3e213f5ff8fe.yaml
+++ b/craft/config/project/dolphiq_sitemap_entries/1d8dd907-afd2-411d-a45b-3e213f5ff8fe.yaml
@@ -1,4 +1,4 @@
 changefreq: weekly
-linkId: fdd1be2c-d545-4af2-9d6a-3a1bb2082e31 # Sectors
+linkId: null
 priority: 0.5
 type: category
diff --git a/craft/config/project/dolphiq_sitemap_entries/6d47467d-1bd2-4ea1-ae48-e17d430cce42.yaml b/craft/config/project/dolphiq_sitemap_entries/6d47467d-1bd2-4ea1-ae48-e17d430cce42.yaml
index 8256fc35..30ccf941 100644
--- a/craft/config/project/dolphiq_sitemap_entries/6d47467d-1bd2-4ea1-ae48-e17d430cce42.yaml
+++ b/craft/config/project/dolphiq_sitemap_entries/6d47467d-1bd2-4ea1-ae48-e17d430cce42.yaml
@@ -1,4 +1,4 @@
 changefreq: weekly
-linkId: c22c47f9-3b49-43b0-906d-a7ae8fcf36ba # International
+linkId: cbcce34a-495a-4916-8335-8d4a3217d194
 priority: 0.5
 type: category
diff --git a/craft/config/project/dolphiq_sitemap_entries/d2bdad24-5ed1-4d5f-88cd-7cb42f7bbfbe.yaml b/craft/config/project/dolphiq_sitemap_entries/d2bdad24-5ed1-4d5f-88cd-7cb42f7bbfbe.yaml
index 22433214..13a98673 100644
--- a/craft/config/project/dolphiq_sitemap_entries/d2bdad24-5ed1-4d5f-88cd-7cb42f7bbfbe.yaml
+++ b/craft/config/project/dolphiq_sitemap_entries/d2bdad24-5ed1-4d5f-88cd-7cb42f7bbfbe.yaml
@@ -1,4 +1,4 @@
 changefreq: weekly
-linkId: 9ca9c766-0fe7-406a-aa76-ef312b1cb6c3 # Services
+linkId: null
 priority: 0.5

This unfortunately will throw an error on running a migration:

- adding dolphiq_sitemap_entries.6d47467d-1bd2-4ea1-ae48-e17d430cce42 ...
error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'linkId' cannot be null
The SQL being executed was: INSERT INTO `craft_dolphiq_sitemap_entries` (`uid`, `linkId`, `type`, `priority`, `changefreq`, `dateCreated`, `dateUpdated`) VALUES ('6d47467d-1bd2-4ea1-ae48-e17d430cce42', NULL, 'category', 0.5, 'weekly', '2021-07-06 15:22:22', '2021-07-06 15:22:22')

I am able to rectify the issue by going into: admin/settings/sitemap and resaving the sitemap settings