I think it would be good to move out frequently changing non static elements from configuration to another storage space. I am thinking about items like max_filesize, updated stamp, links, and context from an xmlsitemap instance. These are constantly changing values (perhaps) and configuration synch will reset them to incorrect values.

Is this a direction you'd like to move forward with?

Background: We export our configuration to a known good configuration for production deployment. We will then bring production db down and run configuration imports locally for feature development ultimately resulting in configuration export as a feature branch is complete and ready to be merged into our production branch.

There are several xmlsitemap configuration entities that are exported. That is known good configuration and we like that. We also export our xmlsitemap instance. Because the instance config is always being updated by new nodes it will always overwrite good data with old data which is not desirable behavior.

Comments

thebruce created an issue. See original summary.

sam152’s picture

Yep, the state API was design for this. For our workflow, these will be reverted every time we deploy.

hctom’s picture

This should defininetely be saved in the state API as it breaks config deployment workflows because you'd deploy wrong config data. Unfortunately this is baked into the xmlsitemap config entity. Are there any reasons for this?

juampynr’s picture

Issue summary: View changes
StatusFileSize
new293.33 KB

Here is what we currently have in the XmlSitemap entity:

XmlSitemap entity structure

Here are a few questions:

  • Which properties should we move to State API?
  • How would we relate a set of properties with an XmlSitemap entity?
  • Shall we totally replace the XmlSitemap entity by State API?
sam152’s picture

I think it should remain a config object, I'm guessing a lot of other parts of the module rely on it and semantically it makes sense, it's an item of configuration created by admins. The only things which should move to states API are the things which change when the sitemap is regenerated on each environment. The ones I can spot are:

-chunks: 1
-links: 168
-max_filesize: 24782
-updated: 1472185784

As far as how they are related? Each sitemap has an ID, why not store them in states API keyed by a combination of the module name and the ID of the sitemap.

plopesc’s picture

Status: Active » Needs review
StatusFileSize
new5.17 KB

Hello

We are having this issue in our current project and proposing here a fix for this. Here is a brief description:

  • Remove environment dependent properties from the XmlSitemap entity definition (chunks, links, max_filesize, updated)
  • Create a XmlSitemapStorage service to manage the XmlSitemap entity operations
  • Create a state variable per XmlSitemap entity to store the environment-dependent data
  • Use the custom XmlSitemapStorage class to update the state data when performing CRUD operation on the XmlSitemap entity

Now, the environment-dependetn data is not being exported, but it is being loaded and stored transparently to end users.

Regards

hctom’s picture

Status: Needs review » Needs work

I just found some time to have a quick look at the provided patch (just checking the patch contents - did not apply it yet), and I guess this is in there by accident, right?

diff --git a/src/Form/XmlSitemapRebuildForm.php b/src/Form/XmlSitemapRebuildForm.php
index 773da0e..f8c9c9f 100644
--- a/src/Form/XmlSitemapRebuildForm.php
+++ b/src/Form/XmlSitemapRebuildForm.php
@@ -100,7 +100,7 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
     // Save any changes to the frontpage link.
-    $entity_type_ids = $form_state->getValue('entity_type_ids');
+    $entity_type_ids = ['node' => 'node'];//$form_state->getValue('entity_type_ids');
     $save_custom = $form_state->getValue('save_custom');
     $batch = xmlsitemap_rebuild_batch($entity_type_ids, $save_custom);
     batch_set($batch);
plopesc’s picture

Status: Needs work » Needs review
StatusFileSize
new730 bytes
new4.44 KB

Thanks @hctom

I completely forgot to remove that line of debugging code.

Attaching now the updated patch and the related interdiff

freelock’s picture

Was just hitting this issue -- We check the config of all production sites nightly, and XMLSitemap is triggering a change every night...

I was thinking of suggesting exactly what you're proposing with this patch -- move the frequently changed things into the State API.

Will apply and see if it works correctly and addresses our needs...

Anonymous’s picture

Works perfectly. I've tested against latest commit.

If no upgrade path is required (the module is still in alpha), I would say that this patch is RTBC.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community
freelock’s picture

Confirmed working for me, too!

  • juampynr committed 24c8474 on 8.x-1.x authored by plopesc
    Issue #2767647 by plopesc, juampynr, freelock, Sam152, hctom, thebruce,...
juampynr’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks everyone!

Status: Fixed » Closed (fixed)

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

dalin’s picture

FWIW, this issue still exists if you try to use
https://www.drupal.org/project/config_readonly
But we can't quite figure out which config variable is still being written to.

Our workaround was to add the configuration name xmlsitemap.xmlsitemap.* into the config readonly whitelist in the settings.php.