Config entities shipped with simple_sitemap are missing certain fields, which makes them incompatible with recipes in certain situations

Created on 15 August 2024, 2 months ago
Updated 7 September 2024, about 2 months ago

Problem/Motivation

One of the important aspects of recipes is that they need to be able to be re-applied. Currently, Simple Sitemap's default config includes some config entities that don't include all of the necessary data - that's normally not a problem because those missing values get filled in when the config is saved, but it breaks the ability to reapply a recipe that installs Simple Sitemap, because the active config (which has had the missing values filled in) differs from the config coming from the module itself!

Steps to reproduce

Create a recipe that installs Simple Sitemap and imports its default config. Apply it once, then apply it again - the second time, it will fail with an exception.

Proposed resolution

Simple Sitemap's config entities should including missing langcode and status values.

πŸ“Œ Task
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
  • Starshot blocker

    A potential blocker for Drupal Starshot. More information: http://www.drupal.org/project/starshot

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • Status changed to Needs review 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Success
    2 months ago
    Total: 485s
    #255169
  • Status changed to Postponed: needs info 2 months ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    I don't see how adding entity keys to configuration that do not exist in the entities themselves solves any problem; rather this seems to be a strange workaround. Neither sitemap nor sitemap type entities have a language code, because a language code does not make sense. Sitemap type entities don't have a status as there is nothing to unpublish. These are custom entity types for a reason - we don't need everything a node entity provides.

    I have not used recipes yet but only taking under account your description, this seems to be more of a problem on their side. Please correct me if you feel I'm wrong.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Neither sitemap nor sitemap type entities have a language code, because a language code does not make sense. Sitemap type entities don't have a status as there is nothing to unpublish.

    They do, actually -- all config entities (well, anything that extends ConfigEntityBase) do. It's defined in the base class. And in fact, one of the shipped entities explicitly has status: false in 4.x HEAD. There's no way to remove the field unless you change the entity type classes to not extend ConfigEntityBase, but that would create more problems than it would solve.

    I have not used recipes yet but only taking under account your description, there seems to be more of a problem with those.

    This is an accurate assessment. Recipes are currently too strict about comparing the active config with the config coming from a recipe (which includes any extensions installed by that recipe). That's a problem that needs to be fixed, but it's a complex issue that I've only begun to work on as a recipe system maintainer. Until that's fixed, though, Simple Sitemap cannot be used with recipes that need to be idempotent (which is, frankly, all of them). Adding missing properties that Simple Sitemap itself may not use, but is in fact responsible for because it extends ConfigEntityBase, seems harmless. Especially because, if you install Simple Sitemap on a brand new plain Drupal and run drush cex, you'll see that those entities have langcode and status. They're there no matter what you think about their usefulness, so the default config might as well reflect that reality. ;)

  • First commit to issue fork.
  • Pipeline finished with Canceled
    2 months ago
    Total: 243s
    #263485
  • Pipeline finished with Canceled
    2 months ago
    Total: 271s
    #263487
  • Pipeline finished with Canceled
    2 months ago
    Total: 90s
    #263491
  • Pipeline finished with Canceled
    2 months ago
    #263497
  • Pipeline finished with Canceled
    2 months ago
    Total: 80s
    #263498
  • Status changed to Needs review 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    I just ran into this working on the SEO recipe for Drupal CMS/Starshot.

    I updated the config files to match the order of what Drupal exports.

    I have changed the status back to Needs review as @phenaproxima has provided additional information to the maintainers.

  • Pipeline finished with Failed
    2 months ago
    Total: 302s
    #263499
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Just as an FYI, this issue is likely to block inclusion of Simple Sitemap in Drupal CMS. :-\

  • Status changed to Needs work 2 months ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    Changing category to task as this is not a bug in my book.

    Just as an FYI, this issue is likely to block inclusion of Simple Sitemap in Drupal CMS. :-\

    And we don't want that to happen, do we? :)

    I updated the config files to match the order of what Drupal exports.

    Looking at the MR diff config/install/simple_sitemap.sitemap.default.yml seems off - ID is changed from 'default' to 'index'

    Please fix that and also look at the sub modules, especially simple_sitemap_engines. Does making a recipe with that module create a similar issue?

    Thanks, I'll make sure to merge that in a timely fashion.

  • Assigned to phenaproxima
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Self-assigning to fix this with test coverage, including all submodules. :)

  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    Off topic, but on the topic of simple_sitemap_engines: To whoever is responsible, maybe it would make sense to include simple_sitemap_engines with its IndexNow functionality into such a Drupal CMS receipe.

  • Pipeline finished with Running
    2 months ago
    #263538
  • Pipeline finished with Canceled
    2 months ago
    Total: 77s
    #263541
  • Pipeline finished with Success
    2 months ago
    Total: 316s
    #263542
  • Issue was unassigned.
  • Status changed to Needs review 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Alright - should be all set.

    Here's the commit which added failing test coverage (all the modules are accounted for): https://git.drupalcode.org/issue/simple_sitemap-3468413/-/pipelines/263538

    And here's the commit which fixed it, to be sure it won't regress in the future: https://git.drupalcode.org/issue/simple_sitemap-3468413/-/pipelines/263542

    Anything else needed here?

  • Pipeline finished with Skipped
    2 months ago
    #263553
  • Status changed to Fixed 2 months ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    That was quick. Looks good, thanks!

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

Production build 0.71.5 2024