Hello,

Problem/Motivation

I was reviewing the code of the AliasManager.php file and noticed that the __construct method has missed the dependency of AliasRepositoryInterface of $alias_repository.

  public function __construct($alias_repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache) {
    $this->pathAliasRepository = $alias_repository;
    $this->languageManager = $language_manager;
    $this->whitelist = $whitelist;
    $this->cache = $cache;
  }

Steps to reproduce

1. Installation of Drupal 9.4.5.
2. Go to the location of the file: /core/modules/path_alias/src/AliasManager.php

Proposed resolution

I have added the AliasRepositoryInterface inside the _construct method.

CommentFileSizeAuthor
#2 missing_dependency-3313448-1.patch895 bytesrakesh.drupal

Comments

rakesh.drupal created an issue. See original summary.

rakesh.drupal’s picture

StatusFileSize
new895 bytes
rakesh.drupal’s picture

Status: Active » Needs review

Kindly review!

cilefen’s picture

Title: Missing AliasRepositoryInterface dependency - path_alias » Missing AliasRepositoryInterface parameter type hint in the AliasManager constructor
hhvardan’s picture

Assigned: rakesh.drupal » Unassigned
Status: Needs review » Reviewed & tested by the community

+1 RTBC

alexpott’s picture

We missed adding this typehint when we removed the deprecated code in #3092090: Remove legacy Path Alias subsystem, Before that was committed we were triggering a deprecation if something with the wrong interface was being passed in.

alexpott’s picture

Version: 9.4.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Fixed

Discussed with @catch - we agreed that committing this to 10.x was the best strategy. We should have added the typehint when we removed the deprecation but we missed it. A new major is good time to add typehints like this - especially given the prior state of the code.

Committed and pushed 946d271597 to 10.1.x and b44b4550ea to 10.0.x. Thanks!

  • alexpott committed 946d271 on 10.1.x
    Issue #3313448 by rakesh.drupal: Missing AliasRepositoryInterface...

  • alexpott committed b44b455 on 10.0.x
    Issue #3313448 by rakesh.drupal: Missing AliasRepositoryInterface...

Status: Fixed » Closed (fixed)

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