Problem/Motivation

While upgrading a site to D9, I ran into an issue that was not caught by upgrade_status: references to the 'path.alias_manager' service. This service has been renamed to 'path_alias.manager'.

Proposed resolution

Check for occurrences of 'path.alias_manager'.

Comments

marcvangend created an issue. See original summary.

marcvangend’s picture

Title: Check for path_alias.manager occurrences » Check for path.alias_manager occurrences
jukka792’s picture

Hi,

I run into same problem, and it is very difficult to find out which module is causing this.

Gábor Hojtsy’s picture

Title: Check for path.alias_manager occurrences » Report changed service name path.alias_manager => path_alias.manager
mglaman’s picture

This should be possible in phpstan-drupal. Opened https://github.com/mglaman/phpstan-drupal/issues/192

Eric_A’s picture

EDIT: drupal-rector catches a bit of this, but not all cases, so only a little bit of inspiration to find there.

FYI, I just did a quick search in one project and found occurrences in the paragraphs_report Drupal module.

palantirnet/drupal-rector catches Drupal::service() calls, but it apparently does not catch arguments to services and retrieving the service from the container. Below is code from paragraphs_report:

services:
  # Expose class as service and pass in config.
  paragraphs_report.report:
    class: Drupal\paragraphs_report\ParagraphsReport
    arguments:
      - '@config.factory'
      - '@entity_field.manager'
      - '@entity_type.manager'
      - '@path.current'
      - '@path.alias_manager'
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('entity_field.manager'),
      $container->get('entity_type.manager'),
      $container->get('path.current'),
      $container->get('path.alias_manager'),
kunalkursija’s picture

+1
I faced this too, where deprecated service usage in Global calls to \Drupal::service('path.alias_manager') are not being called deprecated.

mglaman’s picture

Issue tags: +phpstan-drupal
mglaman’s picture

Deprecations will be reported if you use:

$container->get()
\Drupal::getContainer->get()

The following issue will fix \Drupal::service() calls

https://github.com/mglaman/phpstan-drupal/issues/190

I'll update the issue when it's available to test

mglaman’s picture

Status: Active » Postponed (maintainer needs more info)

The fix for \Drupal::service calls has been added to phpstan-drupal:0.12.15, which should provide all the required coverage for detecting the access of deprecated services.

Can you please run a Composer update to get the latest phpstan-drupal version and verify? If so, we can bump the minimum version for upgrade_status.

Gábor Hojtsy’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks @mglaman. This should fix it for Upgrade Status once people do a composer update.

Gábor Hojtsy’s picture

Status: Fixed » Closed (fixed)

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