Sitemap Variant Add Error

Created on 15 June 2023, over 1 year ago
Updated 21 June 2023, over 1 year ago

Problem/Motivation

When try to add a new sitemap variant (admin/config/search/simplesitemap/variants/add) a follow error appear:

Steps to reproduce

Access sitemap and try to add a variant:admin/config/search/simplesitemap/variants/add
Follow erro appear:
AssertionError: Cannot load the "simple_sitemap_type" entity with NULL ID. in assert() (line 299 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

A follow erro may appear: The website encountered an unexpected error. Please try again later.
AssertionError: Cannot load the "simple_sitemap_type" entity with NULL ID. in assert() (line 299 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

Proposed resolution

Change the web/modules/contrib/simple_sitemap/src/Entity/SimpleSitemap.php::getType() to return null when
the entity doesn't have any type yet "during creation for instance"

🐛 Bug report
Status

Closed: works as designed

Version

4.0

Component

Code

Created by

🇧🇷Brazil rafmagsou

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rafmagsou
  • Status changed to Postponed: needs info over 1 year ago
  • 🇩🇪Germany gbyte Berlin

    Please in the future open up bug reports against the dev version of the module (test the dev version first).

    This error should not be a thing because the form does not allow creating a sitemap without a type and a type should always have an ID.

    Please try and reproduce this on a freshly installed dev version of the module for me and tell me all the steps.

  • 🇧🇷Brazil rafmagsou

    In the context of bug I've checked with 2 types already filled.
    As far a checked here is, some modules that use form alter try get the entity type.

  • 🇩🇪Germany gbyte Berlin

    Please try and reproduce this on a freshly installed dev version of the module for me and tell me all the steps.

  • 🇧🇷Brazil rafmagsou

    As far as I understand the method on getype located on the Entity sitemap:
    Function get type need a proper validation if the type information exists before try load the entity simple_sitemap_type.

    Something like:
    https://git.drupalcode.org/project/simple_sitemap/-/blob/4.x/src/Entity/...

    src/EntitySimpleSitemap.php :: getType

    public function getType():? SimpleSitemapTypeInterface {
    if ($this->isNew()) {
    return NULL;
    }
    .
    .
    .

  • 🇩🇪Germany gbyte Berlin

    What I'm asking you to do is to try and reproduce this on a freshly installed module then explain how you did it. What are the exact steps (a step-by-step explanation) to receive this error? So far you seem the only one to have reported it.

  • Status changed to Closed: works as designed over 1 year ago
  • After some tests on a fresh install the error couldn't be reproduced and the functionality work as expected. Since everything is working I'll close this issue.

Production build 0.71.5 2024