Problem/Motivation

There is a fatal for me using this module.

Steps to reproduce

Create a sitemap and visit the sitemap.xml

Proposed resolution

getPrefix expects the SiteInterface as a first argument.
public function getPrefix(SiteInterface $site, ?string $langcode = NULL): string
It seems like the prefix is being passed here directly.
\Drupal::service('sites_path_prefix.service')->getPrefix($site->getSetting('prefix'))
Which leads to this error:

TypeError: Drupal\sites_path_prefix\SitesPathPrefixService::getPrefix(): Argument #1 ($site) must be of type Drupal\sites\Plugin\Site\SiteInterface, null given, called in /var/www/html/web/modules/contrib/sites_simple_sitemap/src/Manager/GeneratorDecorator.php on line 91 in Drupal\sites_path_prefix\SitesPathPrefixService->getPrefix() (line 47 of modules/contrib/sites/modules/sites_path_prefix/src/SitesPathPrefixService.php).
Drupal\sites_simple_sitemap\Manager\GeneratorDecorator->getContent(NULL) (Line: 54)
Drupal\simple_sitemap\Controller\SimpleSitemapController->getSitemap(Object, 'default') (Line: 18)

So we should pass in the site instead of the prefix.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

n1k created an issue. See original summary.

n1k’s picture

Title: Fatal: etPrefix(): Argument #1 ($site) must be of type Drupal\sites\Plugin\Site\SiteInterface » Fatal: getPrefix(): Argument #1 ($site) must be of type Drupal\sites\Plugin\Site\SiteInterface

harlor made their first commit to this issue’s fork.

  • harlor committed fc9b66af on 1.0.x authored by n1k
    Issue #3538355 by n1k: Fatal: getPrefix(): Argument #1 ($site) must be...
harlor’s picture

Status: Active » Fixed

LGTM

Status: Fixed » Closed (fixed)

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