Closed (fixed)
Project:
Simple XML sitemap
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Sep 2021 at 04:45 UTC
Updated:
20 Jan 2023 at 20:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gbyteComment #3
gbyteDuring a test direct upgrade from 2.x to 4.x I did indeed have a problem that I just fixed here: #3238398: Direct update path 2.x -> 4.x not working.
Apart from the issue above, in all my test runs I had all my settings correctly migrated to 4.x.
Are you sure you updated the database by running
drush updbor visiting /update.php and then exported the configuration? The database needs to be updated on production as well and then the above configuration imported.Would you mind trying to reproduce this issue with 4.x?
Comment #4
realityloop commented@gbyte No, this doesn't seem to be working for me still, after config import the node settings for Simple XML Sitemap are set to do not index for some reason. (see attached image).

And here is the content of the related config export:
simple_sitemap.bundle_settings.default.node.page.yml
Comment #5
realityloop commentedSome further digging it seems the Simple XML Sitemap entity bundle settings aren't getting imported on the config import tyhat occurs during deployment.
If I then run cim again without any changes (not really practical to do in a deployment), they do import:
Comment #6
nuuou commentedI'm seeing the exact same issue noted in #5. We're upgrading sites from 3.x and experiencing this as well.
Right now to get around it, I'm simply running "drush cim" twice in sequence, which seems to fix it on deployments.
Increasing the priority of this to "Major", as this results in lost configuration data if the developer is unaware of this.
Comment #7
abdhomsi commented+1
Comment #8
gbyteI couldn't reproduce it nor do I see any suggestions in this thread on how to fix this behavior.
You guys may be running into #3241439: Config import sometimes needs be run several times to fully sync. Please go through that issue and the attached links and tell me if you think you are experiencing that core bug. Apparently many deployment scripts (not the official one though) suggest running
drush cimtwice.Comment #9
gbyteComment #10
weseze commentedRan into this issue during our update from 3.x to 4.x.
Running the update locally works perfectly fine: (simplified commands)
> drush updb -y && drush cex -y
Then commit to GIT and deploy to our staging environment: (again simplified commands)
> drush updb -y && drush cim -y && drush cr && drush deploy:hook -y
(could also use drush deploy since that does the same thing)
This runs fine, but the actual problem is hidden.
Running drush updb migates all config files (OK)
Running drush cim causes the simple_sitemap configs to be deleted and reimported because the staging environment updb will have created different uuids. The bundle_settings are now not imported because config-import has detected no changes for these files...
So now we are in the broken state.
The main culprit is "simple_sitemap_update_8216()" which can only be run on the active database, it doesn't work in a deployment workflow.
The solution to simply rerun a config-import will actually fix the issue, but does not solve the root cause of the "simple_sitemap_update_8216()" not being "deployable"...
I can see 2 possible solutions for this issue:
1/ Define dependencies within the config files so deleting and recreating config files should be picked up by the config system. (not sure about this one)
2/ Use a deploy hook to fix the broken state after config import: (I'm now using this approach to correctly deploy our updates)
Comment #11
gbyte@weseze
Thanks for your input but what makes simple_sitemap_update_8216() different from other update hooks which use the database and read configuration and what would be the clean way to reimplement this hook in your opinion (other than the workaround you suggested)? Also feel free to create a patch.
Comment #12
weseze commented@gbyte:
First of, it wasn't "simple_sitemap_update_8216", but "simple_sitemap_update_8403"...
I haven't looked at all update hooks, there might be others that cause similar issues. This one was simply the only that caused issues for us.
The basic issue is with creating new configs on update hooks that have some sort of logic or dependant config.
In this case the config files "simple_sitemap.bundle_settings.*.*" are actually somehow dependant on the sitemap configs. I don't know how exactly since I don't have a technical understanding of this module.
The clean way to fix this should be to define config dependencies. I tried doing that directly in the config files and then importing but I was then caught in a hell of dependency chains which I didn't understand. Again, because I don't really now how simple_sitemap works technically...
So for example, in our use case, "simple_sitemap.bundle_settings.default.node.page.yml" contains:
It should contain 2 extra things:
1/ A unique uuid (not sure why this is missing?)
2/ A config dependency to the sitemap configs/entities that use the page content-type. (but I don't know what that would be or how it can be added in the modules logic)
That should in theory allow a deployment workflow to correctly import everything in one go.
The deploy hook I posted previously will also fix the issue and is a much easier solution to the problem ;) Albeit somewhat dirty.
Comment #13
weseze commentedSo, our QA team detected a much bigger issues after the upgrade from 3.x to 4.x. Al of our simple_sitemap_entity_overrides were gone after deployment to QA environment.
So I did some more digging to better understand what all the update hooks, specifically 8403 was actually doing. And to understand what went wrong in a deployment that didn't go wrong when developing the update locally.
The short answer: you should not do config updates in update hooks because they can cause issues in deployments. @see: https://www.drupal.org/project/drupal/issues/3230144#comment-14202410
The long answer: you can get away with most of them and you can fix the issues that it will cause in a deployment in post_update hooks.
The main issue to be fixed here is that new configs are created and old ones deleted through an update hook. This causes different uuids on different environments and a config:import will delete/create, causing complete data loss of any "simple_sitemap_entity_overrides".
Patch attached fixes this by resetting the uuids if they exist in the active sync dir.
This can only be done in a post_update hook.
UPDATE: this should have no effect on existing installs
Comment #14
adamzimmermann commentedUpdating to the 4.x version of this module was something I had shelved as I couldn't get our CI tests to pass and solving this just wasn't a priority at the moment.
During our CI process, we do the usual
drush deploysteps, but then rundrush config:statusat the end to ensure that database config matches the tracked configuration. This config check is where things were failing, in additional to seeing issues similar to what was reported in some of the comments above.After applying this patch our CI process completed without issue and the sitemap is still rendering as expected in the CI preview environment.
I didn't test every detail, but the latest patch solved my immediate issue and things seem to be working as expected afterwards.
Steps:
drush cim -y(start with a clean config state)composer require drupal/simple_sitemap:^4.0composer update --lockdrush updb -ydrush cex -yComment #15
gbyte@weseze
So what's the recommended way of doing them?
I'd appreciate one more pair of eyes before committing, preferably someone else who's had the same problem.
Comment #16
weseze commented@gbyte: there is no easy answer to that question unfortunately... You can read through https://www.drupal.org/project/drupal/issues/3230144 and the materials referenced there to get a better understanding of what is possible in update hooks and what not and how to possibly fix those issues.
Comment #17
jjcarrionI faced the same problem, after updating, all the simple_sitemap config was deleted, so no content types were set up and the sitemap was empty.
Applying patch #13 the config is still there during the deploy process and everything is working again.
Comment #19
gbyteCleaned it up a bit and prevented warnings when configuration does not match database state. Thanks all.
Comment #21
gbyteComment #22
loopy1492 commentedWe were getting this during ci, so we didn't really have a workaround. Thanks for the patch. Looking forward to the next release.
Comment #23
gbyte@loopy1492 The next release already happened.
Comment #24
loopy1492 commentedGosh, sorry @gbyte. So it did. Thanks.